disadvantages of using IQueryable !

我的未来我决定 提交于 2019-12-12 02:28:50

问题


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


回答1:


I don't know how the MongoDB C# binding works, but describe how it usually works:

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.

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.




回答2:


Those are just different interfaces, and as interfaces doesn't contain any implementation it doesn't matter for performance which you use.

When you loop over the values the enumerator of the actual class will be used, regardless of which interface you use to access it.



来源:https://stackoverflow.com/questions/4758467/disadvantages-of-using-iqueryable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!