I have a table that has a sql column with a date as a string like 'January 1, 2018'. I'm trying to turn that into a DateTime object in C# so I can use it to sort a list by. I'm currently grouping everything by the ID so I can return the highest revision. This is working great but I also need to OrderByDescending date from a the column that represents a date. The below code will order everything alphanumerically but I need to sort by DateTime.
using (dbEntities entities = new dbEntities())
{
var db = entities.db_table
.GroupBy(x => x.ID) //grouping by the id
.Select(x => x.OrderByDescending(y =>
y.REVISIONID).FirstOrDefault());
return db.OrderBy(e => e.Date_String).ToList();
}
Thanks, I appreciate any help on this!