Wednesday, February 10, 2016

LINQ to SQL equivalent of select top


Problem

I wanted to get the top 10 rows from a linq query.  I was not sure what the LINQ syntax was.

Solution


var q = from m in MyTable.Take(10)  
select m

or 


if you'd like to get the items from 30 to 60
 
var foo = (From t In MyTable Select t.Foo).Skip(30).Take(30);


No comments:

Post a Comment