How to get the most recent date from a table
c#, date
Solution
You have to order by the date and take one:
var post = UnitOfWork.TableName.Query(postFilter)
.OrderByDescending(x => x.CreatedDate)
.FirstOrDefault();
Problem
I have code where I'm querying something from my table which has a property called `CreateDate`. I just want to get the object with the most recent date. This is what I have: ``` var post = UnitOfWork.TableName.Query(postFilter); ``` I tried using a Max function like this: ``` var post = UnitOfWork.TableName.Query(postFilter).Max(x => x.CreatedDate); ``` but that returns just the date. How do I return a whole object that is the most recent?