使用IQueryable的缺点! [英] disadvantages of using IQueryable !
问题描述
是否存在与使用IQueryable
相关的性能问题?
此外,如果我使用游标而不是使用IQueryable
(那更好).
IQueryable
vs IEnumerable
vs IList
吗?
我使用MongoDB作为数据库.谢谢
Is there are any performance issues related to using IQueryable
?
Besides, if I use a cursor instead of using IQueryable
(is that better) .
IQueryable
vs IEnumerable
vs IList
?
I use MongoDB as my database . Thank you
推荐答案
我不知道MongoDB C#绑定的工作原理,但描述它通常如何工作:
I don't know how the MongoDB C# binding works, but describe how it usually works:
使用IQueryable
时,将构建一个表达式树,然后将其转换为数据库可以理解的格式,然后在数据库服务器中执行.
When using IQueryable
an expression tree is constructed, then translated into a format the database can understand and then executed in the database-server.
与直接以数据库可理解的格式编写查询相比,这通常具有较小的开销(构造表达式树并对其进行翻译).
This typically has a small overhead(construct expression tree and translate it) compared to directly writing queries in the format the database understands.
与IEnumerable
一起使用委托,而不是表达式.它需要遍历完整的数据集,然后使用Linq-To-Objects进行过滤.这要慢得多.
With IEnumerable
delegates are used, instead of expressions. It needs to iterate over the complete dataset and then filters using Linq-To-Objects. This is much slower.
这篇关于使用IQueryable的缺点!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!