Monday, November 2, 2009

order by in LINQ (basic example)

I have a table of filters from wich I want to get my last ID inserted , so I thought that I would sort in descending first and get the first element of the list.

Here's how to do a simple task like this.


var firstFilter = db.Filters.OrderByDescending(f => f.id).FirstOrDefault();






No comments: