Entity Framework的SQL查询执行 [英] Entity Framework SQL Query Execution

查看:385
本文介绍了Entity Framework的SQL查询执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用实体框架,当一个执行一个查询就可以说2000上所录制需要GROUPBY和其他一些计算,确实查询获取服务器上执行,只有结果发送到客户端或者是所有发过来在客户端,然后执行?



这使用SQL Server。



我期待这个,因为我M将要开始一个项目,就会有一个庞大的数据库所需查询的负载,想知道这是否会产生网络上的显著负荷,如果使用的是实体框架。


< DIV CLASS =h2_lin>解决方案

我想所有的数据库查询是在服务器端完成(如数据库!),结果传过来。然而,在LINQ的你有什么作为延迟执行(延迟加载),因此您的信息是不实际检索,直到您尝试访问它如调用了ToList()或访问属性(相关表格)。



您必须使用的 LoadWith 做,如果你需要它预先加载。



所以在性能方面,如果你只是真的想1个旅行到数据库查询(其中已相关的表)我会使用 LoadWith 选项建议。但是,它真的取决于具体情况。


Using the Entity Framework, when one executes a query on lets say 2000 records requiring a groupby and some other calculations, does the query get executed on the server and only the results sent over to the client or is it all sent over to the client and then executed?

This using SQL Server.

I'm looking into this, as I'm going to be starting a project where there will be loads of queries required on a huge database and want to know if this will produce a significant load on the network, if using the Entity Framework.

解决方案

I would think all database querying is done on the server side (where the database is!) and the results are passed over. However, in Linq you have what's known as Delayed Execution (lazily loaded) so your information isn't actually retrieved until you try to access it e.g. calling ToList() or accessing a property (related table).

You have the option to use the LoadWith to do eager loading if you require it.

So in terms of performance if you only really want to make 1 trip to the Database for your query (which has related tables) I would advise using the LoadWith options. However, it does really depend on the particular situation.

这篇关于Entity Framework的SQL查询执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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