使用ObjectContext获取数据 [英] Getting data with ObjectContext

查看:81
本文介绍了使用ObjectContext获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道以下Linq查询如何执行



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;





以上代码是否会从每个表中获取数据处理Web服务器中的查询还是修改查询并将单个查询语句发送到数据库服务器?



谢谢,

Prasaadsj



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

推荐答案

当您在支持asp.net的Web服务器(IIS)上运行上面的实体查询时,实体框架会将其转换为transact sql查询(T-SQL)和发送回Sql server.之后,sql server运行请求的sql查询,结果将再次发送回Web服务器。这就是看到后面发生的情况。



如果您想了解更多关于实体框架生成的T-SQL代码,可以使用多个Tools.Such是LINQPad,SQL Server Profiler和Visual Studio Debugger等。

如果你我需要知道你可以查看下面提到的文章的那些工具tten.It的标题为如何将Linq实体查询转换为T-SQL?:



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





我希望这会对你有所帮助。
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.


这篇关于使用ObjectContext获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆