我在升级到EF Core 3.0时遇到了一些问题,在2.2上运行良好的查询不在3.0上运行。例如以下查询:
var grpedClientData = (from o in db.TicketEvent
where o.ClientId != null && o.SiteId != null && o.DateUtc >= dateHourUTC && o.DateUtc < toDateUTC
group o by new { o.ClientId, o.SiteId, o.OperatorId, o.TicketTypeId, o.ScannerId, o.ClientBookingId, o.TicketSaleOrderId, o.TicketSaleOrderEntryId } into g
select new StatsSummarySiteVisit
{
DateHourVisitedUtc = dateHourUTC,
SiteId = (int)g.Key.SiteId,
OperatorId = g.Key.OperatorId,
ScannerId = g.Key.ScannerId,
TicketTypeId = g.Key.TicketTypeId,
ClientId = g.Key.ClientId,
NumUnique = g.Where(t => t.TicketEventType.IsPermittedEntry).Select(t => t.TicketId).Distinct().Count(), //issue is here
NumNonUnique = g.Count(t => t.TicketEventType.IsPermittedEntry),
NumRejectedUnique = g.Where(t => t.TicketEventType.IsDeniedEntry).Select(t => t.TicketId).Distinct().Count(), //issue is here
NumRejectedNonUnique = g.Count(t => t.TicketEventType.IsDeniedEntry),
IsLocalIdcard = false,
DateLockedUtc = lockDateUTC,
ClientPreBookingId = g.Key.ClientBookingId,
TicketSaleOrderId = g.Key.TicketSaleOrderId,
TicketSaleOrderEntryId = g.Key.TicketSaleOrderEntryId
}).ToList();
我遇到以下错误:
LINQ表达式'AsQueryable(Where( 来源:NavigationTreeExpression 值:默认值(IGrouping <<> f__AnonymousType1,Nullable,Nullable,Nullable,Nullable,Nullable,Nullable,Nullable>,TicketEvent>) 表达式:(未处理的参数:e), 谓词:(t)=> t.TicketEventType.IsPermittedEntry))由'NavigationExpandingExpressionVisitor'失败。这可能表示EF Core中存在错误或限制。有关更多详细信息,请参见https://go.microsoft.com/fwlink/?linkid=2101433。
如果有人可以提供帮助,尤其是如何重写它,使其在3.0上可以运行,则不胜感激。