Can someone explain to me why the following statement:
var record = _efEntities.Records.LastOrDefault();
Throws this error:
System.NotSupportedException was unhandled
Message="LINQ to Entities does not recognize the method 'EFSchedulerDemo.Resource Last[Resource](System.Linq.IQueryable`1[EFSchedulerDemo.Resource])' method, and this method cannot be translated into a store expression."
But I am able to use:
var record = _efEntities.Records.ToList().LastOrDefault();
How can I get the first or last record without having to call ToList() every time if possible?