I had asked a question about this before but my database structure has changed, and when it simplifies other things Now, this part is more complex. The last question is
At that time, there was a user project object in my EF context because there were other properties now that when I simplified that table, then this is just a key, so all my EF is aware of reference < Code> user and projects
and the M2M connection between them.
In SQL, this will be something like this :
Select user to join user on project. Id = user project UserAd where in the project ID)
and I started in EF with something like this:
code myProjects = (p to edmx.Projects where P.Users.Contains (edmx .supers.firster Default (U = & gt; UEmail == User E-mail)) P. Names P. Choose P) .Oolist (); Var connected user = (in edmx from U. user where myProjects.Contains (?????????) // where myProjects.Any (select ???));
What is the trick ???????? Is putting in. Anybody here helps?
var me = context the user. First (user = & gt; user.Email = "me@example.com"); // Note that ToList () or AsEnumerable () does not have any call Var myProjects = Reference Projects Where (project => project.parts.company (my)); Var associatedUsers = Reference. Where (user = & gt; myProjects.Any (project = & gt; user.Project.Contains (project));
But there are many other possible solutions for example
var associated user = myProjects Selection Main (Project => Project. User) Undoubtedly ();
Which I like
Further note that instead of receiving myProjects
, contains ()
.
var myProjects = me.Projects;
Comments
Post a Comment