c# - 如何在 Linq 中使用 Long 类型作为 Skip

标签 c# linq

我如何在 Linq 中将长类型 (Int64) 与 Skip 一起使用。它仅支持 Int32。

dataContext.Persons.Skip(LongNumber);

最佳答案

您可以使用 while 循环:

// Some init
List<Person> persons = new List<Person>();
List<Person> resultList = persons;
long bigNumber = 3 * (long)int.MaxValue + 12;

while (bigNumber > int.MaxValue)
{
    resultList = resultList.Skip(int.MaxValue).ToList();
    bigNumber -= int.MaxValue;
}
resultList = resultList.Skip(int.MaxValue).ToList();
// Then what do what you want with this result list

但是您的集合中是否有超过 int.MaxValue 个条目?

关于c# - 如何在 Linq 中使用 Long 类型作为 Skip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32309807/

相关文章:

c# - 我如何关闭大写锁定键

c# - 将日期时间字符串列表转换为日期时间值列表

c# - 使用 Linq 过滤 ComboBox.DataSource?

c# - LINQ "Where"条件 -> 更改属性值

c# - 比较两个数据集 - 查找更改 - LINQ

c# - 将接口(interface)与 WCF 结合使用

c# - 带有术语汇总的Elasticsearch日期直方图报告

c# - Linq 查询从 Sql 数据库返回重复记录

c# - 在运行时修改 linq 查询

c# - *.json 文件更改后 IOptionsSnapshot 不刷新