c# - query that gets only the records needed to the page using Linq- not fetched the record based on page size -


i have used query fetch record of datatable based on pagesize.

   ienumerable<datarow> query1 = row in dt.asenumerable().take(page_size).skip(offset) select row; 

datatable boundtable= query1.copytodatatable();

first time when opens offset =0; gives 10 records,

next time pass offset 10 next ten records, not giving enum values. showing me message says ' enumeration yielded no results '

but dt querying has 1000 records. wrong made here...

you're using skip , take in wrong order. try this:

ienumerable<datarow> query = dt.asenumerable()                                .skip(offset)                                .take(pagesize); 

(i removed query expression syntax wasn't doing favours here.)

you doing take skip - saying like, "give me first ten records, skip eleventh of ten." that's not going give results :)

the above says, "skip eleventh record, give me first ten records left."


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -