c# - For loop on Data table on condition -
i have result dataset,
dataset dsresult = new dataset();
dsresult.tables[0].rows.count = 17
now want loop through data table first 5 rows , create dsresult.tables[1]
and next 5 more rows dsresult.tables[2]
and next 5 more dsresult.tables[3]
then last 2 rows dsresult.tables[4]
from below code getting number of tables required
decimal remainder = decimal.divide(dsresult.tables[0].rows.count, 5); var numberofrequests = math.ceiling((decimal)remainder);
or can in sql
how genaralize logic.
please guide me here.
using linq simple
var firstfive = dsresult.tables[0].asenumerable().take(5); var secondfive = dsresult.tables[0].asenumerable().skip(5).take(5);
and on.
not loop, let linq you.
if later need convert results datatables msdn has example on how creating datatable query (linq dataset)
Comments
Post a Comment