I am trying to get the latest record for the logged in employee in my HolidayRequestForm
table.
However based on advice from LINQ To Entities does not recognize the method Last. Really? I want to orderbydescending and select the first.
I've tried adding in orderbydescending but I get an error
"Error 3 'System.Data.TypedTableBaseExtensions.OrderByDescending(System.Data.TypedTableBase, System.Func, System.Collections.Generic.IComparer)' is a 'method', which is not valid in the given context
"
Do I have it in the wrong place?
var SD = (from c in db.HolidayRequestForms.OrderByDescending
where (c.Employee.Email == name) && (c.Employee.EmployeeID == c.EmployeeID)
select c.StartDate);
DateTime StartDate = SD.LastOrDefault();
I would like StartDate
to give the latest result in the HolidayRequestForm
table for the current logged in employee