I am trying to understand some fundamental best practices using the Entity Framework.
My EDM project has Group and User objects that can contain groups and users.
The question arises:
What is the best way to get users out of a group?
To simplify groups, simply create a context object and create a list from the group table.
But when I want to see users inside the group, the context closes (as it should be).
I thought of two approaches:
1) sending the group back, binding it to the context and using the Load () method for users and returning the list of users.
Here I do not know when to join, and when I should not and when EDM will grow, I will have to do a lot back and forth for each download link
2) linq request from the user side.
from u in context. Users where u.Groups.Contains (group) choose u
Here I get an exception that only primitive types can use.
So what is the right way to do this?
Thanks Ronny
Ronny source
share