Entity framework linq to entities -
Before I wanted to get related data in a SQL query, I would have been included in tables, but now in linq Data related to tables in the institutions that I want to receive, which are related to the table through any other table, I do not know how to do this kind of queries for the institutions in the links. If someone can do good then it would be good.
Example table is a person who is concerned with table users that are related to table roles. I want to be able to get a person who has a special role because the person is related only to the user and indirectly for the role of the user, I am not sure about the query, besides using the navigation property Do not get me all the way while doing
Any information will be good. Here is an example of database structure:
If you use the generator Are VS (I.e., the dip drop down data table and diagrams and keys are all set in DB), then what you are asking for may already be automatic.
For example
from person in context. Presentations in which the person Name == Select "Peter Pan" person. User: Roll. Roll name;
The exact name needs to be referred to the code generator, but this is the idea. Links will help foreign countries for organizations and mapping them for you.
Edit
Actually I have not tried to use them. But according to this, the object hierarchy should be shown for it to be included. Therefore, to work your query, try:
Include in db.Persons.Include ("aspnet_Users"). Include ("aspnet_roles") where c.aspnet_Users.aspnet_Roles.RoleName == select "role" c
And besides, will you consider starting with roles?
Choose r.RoleName == "ROLE". R.aspnet_Users.Persons
Comments
Post a Comment