Understanding the implications of IQueryable<T>
来源:互联网 发布:淘宝商家店铺状态异常 编辑:程序博客网 时间:2024/05/20 19:33
Understanding the implications of IQueryable<T>
IQueryable<T> is a very powerful feature that enables a variety of interesting deferred execution scenarios (like paging and composition based queries). As with all powerful features, you want to be careful with how you use it and make sure it is not abused.
It is important to recognize that returning an IQueryable<T> result from your repository enables calling code to append on chained operator methods to it, and so participate in the ultimate query execution. If you do not want to provide calling code this ability, then you should return back IList<T> or IEnumerable<T> results - which contain the results of a query that has already executed.
For pagination scenarios this would require you to push the actual data pagination logic into the repository method being called. In this scenario we might update our FindUpcomingDinners() finder method to have a signature that either returned a PaginatedList:
PaginatedList< Dinner> FindUpcomingDinners(int pageIndex, int pageSize) { }
Or return back an IList<Dinner>, and use a "totalCount" out param to return the total count of Dinners:
IList<Dinner> FindUpcomingDinners(int pageIndex, int pageSize, out int totalCount) { }
IQueryable<T> is a very powerful feature that enables a variety of interesting deferred execution scenarios (like paging and composition based queries). As with all powerful features, you want to be careful with how you use it and make sure it is not abused.
It is important to recognize that returning an IQueryable<T> result from your repository enables calling code to append on chained operator methods to it, and so participate in the ultimate query execution. If you do not want to provide calling code this ability, then you should return back IList<T> or IEnumerable<T> results - which contain the results of a query that has already executed.
For pagination scenarios this would require you to push the actual data pagination logic into the repository method being called. In this scenario we might update our FindUpcomingDinners() finder method to have a signature that either returned a PaginatedList:
PaginatedList< Dinner> FindUpcomingDinners(int pageIndex, int pageSize) { }
Or return back an IList<Dinner>, and use a "totalCount" out param to return the total count of Dinners:
IList<Dinner> FindUpcomingDinners(int pageIndex, int pageSize, out int totalCount) { }
- Understanding the implications of IQueryable<T>
- The Understanding of KMP
- the understanding of the MVC architecture
- Performance Implications of Database Snapshots
- Understanding the basis of Java I18n
- Understanding the concepts of Object Oriented Programming
- Understanding the different versions of VMWare
- Understanding the parallelism of a Storm topology
- The understanding of string in C.
- Understanding the parallelism of a Storm topology
- Understanding the parallelism of a Storm topology
- Understanding of The VLAN 802.1Q tag
- Understanding the Parallelism of a Storm Topology
- Understanding the Internal Message Buffers of Storm
- Understanding the nature of ARM PC register
- Understanding the Parallelism of a Storm Topology
- understanding the kernel of the linux the third vesion
- 通过IQueryable<T>获得DbContext
- Mac上制作Ubuntu USB启动盘
- Linux下安装与配置snmp服务
- linux环境sqlplus中使用backspace键出现乱码的解决
- java中String.format()的用法
- sql一些语句性能及开销优化
- Understanding the implications of IQueryable<T>
- 简单标签解决防盗链问题源码
- RTP/RTSP/RTCP的区别
- 飞思卡尔 HCS12(x) memory map解说(1) .
- Handling the AUDIO_BECOMING_NOISY Intent
- 问答平台Piazza推出移动版应用
- 解决is not in the sudoers file问题
- 设置activity为Dialog类型的设置
- linux-Vi使用方法(备查)