views:

38

answers:

2

We have a query for about 40 data fields related to customers. The query will often return a large amount of records, say up to 20,000. We only want to use say around the first 500 results. Then, we just want to be able to page through them 10 at a time.

Is LINQ skip and take a reasonable approach for this? Are there any potentnialy performance issues with using this approach vs doing it manually some other way?

+1  A: 

Yes, if you're on SQL Server 2005+ it'll generate SQL that uses the ROW_NUMBER() function to make paging efficient (not unlike the SQL that Scott uses in this blog post).

Dean Harding
+4  A: 

Take() without Skip() generates SQL using TOP clause.

Take() with Skip generates SQL using ROW_NUMBER() as shown here.

Also, I'd recommend to use excellent LINQPad tool or LINQ to SQL logging to check generated queries.

elder_george