[HowTo] Select Top x using Linq

If you wish to make such a query :
Select top 10 Foo from MyTable

use the .Take(x) method :

var foo = (from t in MyTable
           select t.Foo).Take(10);

In VB LINQ has a take expression:

Dim foo = From t In MyTable  
          Take 10  
          Select t.Foo

Leave a Reply