“Unable to create a constant value of type 'User'” when using FirstOrDefault?
问题 I have a method called UpdateOrders that is supposed to allow users to only edit orders that they own, unless the user is an administrator, in which case they can edit all orders. I'm using Entity Framework 5 in .NET 4.5. The following code produces the error "Unable to create a constant value of type 'User'" at the line var target = _context.Orders.FirstOrDefault... . public Order UpdateOrders(Order order) { var userName = HttpContext.Current.User.Identity.Name.ToLower(); var target =