在.NET Core 2中,下面显示的代码完美运行,在.NET Core 3和实体框架中,它失败了。我已经看过此链接,但是我无法确定它到底对什么感到不满意,或者为什么它评估不正确。
PersistenceManager.Context
.Message.AsNoTracking()
.Where(x => roles.Contains(x.BusinessId.ToString())
&& x.Direction == "IN" && x.IsRead == false
&& x.Date >= date)
.GroupBy(r => r.ClientId)
.Select(g => g.OrderByDescending(p => p.Date)
.FirstOrDefault())
.Include("Client");
服务器输出的问题似乎是:
source: NavigationTreeExpression
Value: default(IGrouping<Nullable<Guid>, Message>)
Expression: (Unhandled parameter: e),
keySelector: (p) => p.Date))' by 'NavigationExpandingExpressionVisitor' failed.
This may indicate either a bug or a limitation in EF Core. See https://go.microsoft.com/fwlink/?linkid=2101433 for more detailed information.