简体   繁体   English

如何在Datatable Asp.net Core 2.0 中应用skip and take

[英]How to apply skip and take in Datatable Asp.net Core 2.0

Is there any way to apply skip and take in Datatable in asp.net core 2.0.有什么方法可以在 asp.net 核心 2.0. without converting to any class type?不转换为任何 class 类型? I have used stored procedure to get data and convert to Datatable, I want to apply pagination in this Table, how can I do this?我已经使用存储过程来获取数据并转换为 Datatable,我想在这个表中应用分页,我该怎么做?

You can not use becuase it does not implement the IEnumerable<T> .您不能使用,因为它没有实现IEnumerable<T> But you can do this by using AsEnumerable extension method.但是您可以通过使用AsEnumerable扩展方法来做到这一点。

DataTable dt = new DataTable();
IEnumerable<DataRow> rows = dt.AsEnumerable().Skip(10).Take(10);

Above solution works for.Net Core version >= 3上述解决方案适用于.Net Core 版本 >= 3

For.Net Core version 2. You need to install the package. For.Net Core 版本 2. 需要安装 package。

System.Data.DataExtensions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM