tags:

views:

76

answers:

2

I want to get, let's say 100 records from an already populated DataTable with let's say 150.000 records. I don't wanna do this with a loop or importing rows. There should be a more efficent and easy way to do this, and i'm not finding it. I tried using

myDataTable.Select("ROWNUM < 100"); // because i'm working with oracle

but RowNum is not a column of the table.

Any hint and help is highly appreciated! Thnx in advance.

A: 

You may want to look at this answer to a similar question on Paging Mechanisms

Hooloovoo
+2  A: 

If you're using .NET 3.5, you can use the AsEnumerable extension method, and then Take:

IEnumerable<DataRow> rows = myDataTable.AsEnumerable().Take(100);

Are you sure you can't do this at population time though? You don't really want to be pulling 150,000 items from the server if you can help it...

Jon Skeet