Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to partitioning or splitting DataTable in C#?

Tags:

c#

sql

datatable

I want to split DataTable so that I can upload its chunks from one place to other.

For example

pick first 100 rows.
pick next 100 rows.
pick next 100 rows and so on ...

Is there any way to do it just like cursor in Database? I do not like to use loops etc. for counting rows.

like image 411
NASSER Avatar asked Nov 15 '11 06:11

NASSER


1 Answers

YourDataTable.Select() gives you an array of Data

What about linq?

Fro example YourDataTable.Select (x => x).Take (100).ToEnumerable() gives you the first 100 DataRows and YourDataTable.Select (x => x).Skip(100).Take (100).ToEnumerable() for the next 100.

like image 197
Yahia Avatar answered Oct 22 '22 00:10

Yahia