为什么我使用此LINQ表达式得到以下错误:
Models.Order last = context.Orders.LastOrDefault(o => o.customerID == customer.customerID);
而不是这个:
Models.Order last = context.Orders.Where(o => o.customerID == customer.customerID).OrderByDescending(o => o.orderID).ToList()[0];
错误:
System.NotSupportedException: LINQ to Entities does not recognize the
method 'Corporate.Models.Order LastOrDefault[Order](System.Linq.IQueryable`1
[Corporate.Models.Order], System.Linq.Expressions.Expression`1[System.Func`2
[Corporate.Models.Order,System.Boolean]])' method, and this method cannot be
translated into a store expression.