System.NotImplementedException in EntityFramework linq query?

余生长醉 提交于 2020-01-17 17:27:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!