How do I do this
Select top 10 Foo from MyTable
in Linq to SQL?
For limit 1
use methods FirstOrDefault()
or First()
.
Example
var y = (from x in q select x).FirstOrDefault();
I had to use Take(n) method, then transform to list, Worked like a charm:
var listTest = (from x in table1
join y in table2
on x.field1 equals y.field1
orderby x.id descending
select new tempList()
{
field1 = y.field1,
active = x.active
}).Take(10).ToList();