Offset/Fetch based paging (Implementation) in EntityFramework (Using LINQ) for SQL Server 2008(SQL Server 2008 EntityFramework(使用 LINQ)中基于偏移/获取的分页(实现))
问题描述
我正在使用 SQL Server 2008 和 Entity Framework 6.1.3.我希望基于 OFFSET/FETCH 而不是 Take() &跳过().
I am using SQL Server 2008 and Entity Framework 6.1.3. I wish to implement pagination of data based on OFFSET/FETCH rather than Take() & Skip().
我在网上搜索没有运气.一些帖子建议迁移到 SQL Server 2012.在我的情况下,这不是一个选项.
I searched online with no luck. Some posts suggested migrating to SQL Server 2012. Which is not an option in my case.
有人可以建议如何在 SQL Server 2008 和 EF 6.1.3 中使用 OFFSET/FETCH
Can someone suggest how to use OFFSET/FETCH with SQL Server 2008 and EF 6.1.3
推荐答案
这可以通过 Entity Framework 6.1 实现.2 及以上,所以你应该可以在你的项目中使用它.标准的 Skip 和 Take 方法无法像其他方法一样被捕获.现在有两个额外的使用 lambda 的 Skip/Take 方法重载,所以不要这样:
This is possible with Entity Framework 6.1.2 and above so you should be OK to use it in your project. The standard Skip and Take methods can't be captured in the same way as others. There are now two additional overload of the Skip/Take methods that take lambdas, so instead of this:
var results = context.MyTable
.Skip(10)
.Take(5);
这样做:
var results = context.MyTable
.Skip(() => 10)
.Take(() => 5);
这篇关于SQL Server 2008 EntityFramework(使用 LINQ)中基于偏移/获取的分页(实现)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server 2008 EntityFramework(使用 LINQ)中基于偏移/获取的分页(实现)


基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01