Reputation: 13985
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?
Upvotes: 3
Views: 2921
Reputation: 7879
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.
Upvotes: 6
Reputation: 72658
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).
Upvotes: 2