我如何在 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/