问题
Code:
var query = await _messageGroupRepository.GetAll()
.Include(x => x.Users)
.Where(x => x.Users.Any(y => y.Id == 1))
.OrderByDescending(x => x.Date)
.Take(5)
.ToListAsync();
Result: System.NotImplementedException
Solution?
回答1:
Welcome to StackOverflow. The NotImplementedException is typically used as a placeholder in methods which are not yet implemented (as the name suggests). It should rarely occur with production code and I don't think I have ever seen it in a mature framework or library (like LINQ).
In your case, I would guess that it is the GetAll() method on your repository which throws the exception (but you can check the stacktrace), as it is the only non-LINQ method there.
回答2:
MSDN:
The exception that is thrown when a requested method or operation is not implemented.
Solution: find a method without implementation and fix it.
来源:https://stackoverflow.com/questions/59750459/system-notimplementedexception-in-entityframework-linq-query