The Equivalent Of TOP In LINQ to SQL



TODO:

Have you ever wanted to use the SQL equivalent of TOP in LINQ to SQL?  To do so, you can use the 'Take()' method

 

SOLUTION:

var custquery = (from c in MyContext.Customers
       select new
       {
              c.Id,
              c.FirstName,
              c.LastName
       }).Take(1000);

return custquery.ToDataTable();

 

NOTES:

There are no notes on this topic.



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading