实体框架groupby投掷invalidoperationException
我正在尝试groupby
基于连接表的结果。
var services = await db.Services.AsNoTracking()
.Include("Visit")
.Where(s => !s.Cancelled && s.AmtToPay > 0 && patientIds.Contains(s.Visit.PatientNo) && s.DTS < day)
.GroupBy(s => s.Visit.PatientNo)
.ToListAsync(cancellationToken);
不幸的是,此groupby
导致异常:
system.invalidoperationException:客户端投影包含对'Microsoft.entityframeworkcore.metadata.ipropertybase'的常数表达式的引用,该表作为参数传递给方法为'valityBuffertryReadValue'的参数。这可能会导致内存泄漏;考虑将此常数分配给局部变量,然后使用查询中的变量。参见 https://go.microsoft.com/fwlink/?有关更多信息。
这并不能真正解释情况。在这种情况下,如何使用groupby
?
I'm trying to GroupBy
my results based on a joined table.
var services = await db.Services.AsNoTracking()
.Include("Visit")
.Where(s => !s.Cancelled && s.AmtToPay > 0 && patientIds.Contains(s.Visit.PatientNo) && s.DTS < day)
.GroupBy(s => s.Visit.PatientNo)
.ToListAsync(cancellationToken);
Unfortunately this GroupBy
causes an exception:
System.InvalidOperationException : The client projection contains a reference to a constant expression of 'Microsoft.EntityFrameworkCore.Metadata.IPropertyBase' which is being passed as an argument to the method 'ValueBufferTryReadValue'. This could potentially cause a memory leak; consider assigning this constant to a local variable and using the variable in the query instead. See https://go.microsoft.com/fwlink/?linkid=2103067 for more information.
Which doesn't really explain the situation. How do I use GroupBy
in this situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选择
应在groupby
之后添加EntityFramework Core中,根据 ef core 3.1折断3.1破坏说明
select
should be added aftergroupby
in EntityFramework Coreaccording to ef core 3.1 breaking changes notes