Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to know how the following Linq query executes

var query = from teamRoles in this.ObjectContext.TRoles
                        join team in this.ObjectContext.Teams on teamRoles.teamId equals team.id
                        join teamMembers in this.ObjectContext.TMembers on team.id equals     teamMembers.teamId
                        join agent in this.ObjectContext.Agents on teamMembers.agentId equals agent.id where team.agencyId == agencyId  && teamRoles.role == (int)role
                        select agent;


Does the above code will get data from each table and process the query in the web server or will it modifies the query and send a single query statement to Database server?

Thanks,
Prasaadsj
Posted
Comments
Jameel VM 13-Sep-13 2:32am    
go through this http://www.codeproject.com/Articles/383749/How-does-it-work-in-Csharp-Part-3-Csharp-LINQ-in-d

1 solution

When you run above entity query on asp.net enabled web server (IIS),Entity framework will convert it into a transact sql query (T-SQL)and send back to the Sql server.After that the sql server runs the requested sql query and result will send back to the web server again.That is the scenario happening behind the seen.

If you would like to know more about the entity framework generated T-SQL code,you can use number of Tools.Such are LINQPad,SQL Server Profiler and Visual Studio Debugger etc.
If you need to know about those tools you can check below mentioned article which I have written.It's Title as "How to Convert Linq Entity Query into T-SQL ?":

http://sampathloku.blogspot.com/2012/08/how-to-convert-linq-entity-query-into-t.html[^]


I hope this will help to you.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900