EntityFramework DbContext - DbSet Local属性 - 性能 [英] EntityFramework DbContext - DbSet Local property - performance
问题描述
Hallo,
我有一些小应用程序(主要是WinForms)使用DbContext - DbSet Local属性 - 主要是因为双向绑定等等。现在,我尝试使用这种方法为
换一张更大的桌子而且我坚持表演。
一个名为Tests的简单表格只有一列 - 具有cca 500 000记录的属性ID(标识列,主键)需要cca 38分钟才能得到结果:
MyContext.Tests.Load ; $
var r = MyContext.Tests.Local;
$
另一方面,以下命令仅需要cca 8秒:
var r = MyContext.Tests.ToList();
$
我知道,不要得到很多来自数据库的记录,使用过滤器等 - 但只是假设我需要它。
你能否建议我另一种方法,我可以用于双向绑定而不用当地的财产?因为它看起来这是互联网搜索建议的唯一方式...
一个名为Tests的简单表只有一列 - 属性ID(标识列,主键),cca 500 000条记录需要cca 38分钟才能得到结果:
这是关于什么类型的应用程序将读取500K的记录?永远不应该在批处理场景中使用ORM,长时间运行的I / O繁重的作业。 ORM适用于快速击中者进入,获取和关闭连接,例如
客户端/服务器应用程序。
Hallo,
I have some small applications (mostly WinForms) using DbContext - DbSet Local property - mainly because of the two-way binding and so on. Now, I have tried to use this approach
for a bigger table and I am stuck on the performance.
A simple table named Tests just with only one column - property ID (identity column, primary key) with cca 500 000 records takes cca 38 minutes to get the result:
MyContext.Tests.Load;
var r = MyContext.Tests.Local;
On the other side, the following command takes just cca 8 seconds:
var r = MyContext.Tests.ToList();
I know, do not get a lot of records from database, use filters etc. - but just suppose I need it.
Can you suggest me some another approach which I can use for the two-way binding without the Local property? Because it looks this is the only way which is suggested by Internet searching ...
A simple table named Tests just with only one column - property ID (identity column, primary key) with cca 500 000 records takes cca 38 minutes to get the result:
And this is in regards to what type of application is going to read 500K of records? An ORM should never be used in a batch processing scenario, long running jobs with heavy I/O. An ORM is for quick hitters get in, get and close the connection, like for client/server applications.
这篇关于EntityFramework DbContext - DbSet Local属性 - 性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!