Home / Code Snippets / Blog article: Get Last Row From Table Using LINQ To SQL

| RSS

Get Last Row From Table Using LINQ To SQL

March 9th, 2009 | No Comments | Posted in Code Snippets

This query returns the last row from Sales.Customer table in Adventure Works database. I am using LINQPad to write and execute my query.

(from c in Customers
select c)
.OrderByDescending(x=> x.CustomerID).First()

 

Here is the result as displayed in LINQPad

 image

Leave a Reply 7518 views, 5 so far today |

Leave a Reply