gpt4 book ai didi

linq - 我对 LINQ 表达式有一些问题,OrderBy()、Skip()、Take() 工作不正确

转载 作者:行者123 更新时间:2023-12-04 21:23:40 25 4
gpt4 key购买 nike

我有像这样的 LINQ 表达式

var a = ctx.EntitySet
.OrderByDescending(t => t.Property)
.Skip(pageIndex * size)
.Take(size);

OrderBy() 应该在 Skip() 和 Take() 之前调用,但排序发生在最后。我能解决这个问题吗?

对不起,很多人没有理解我的问题。查询运行没有任何错误,但我想要
//It is I want
1) Sorting ALL data
2) Use Skip() and Take()

如果我喜欢我的例子,我会得到什么结果:
1) 跳过()
2) 取()
3)只对获取的元素进行排序!

最佳答案

我不知道为什么,但不知何故它对我有用,希望对你有帮助

var a1 = from p in ctx.EntitySet
.OrderByDescending(t => t.Property)
select p;

var a2 = from p in a1
.Skip(pageIndex * size)
.Take(size)
select p;

关于linq - 我对 LINQ 表达式有一些问题,OrderBy()、Skip()、Take() 工作不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7467815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com