这里是我想从我的OData源运行查询:如何用OData和LINQ进行嵌套计数?
var query = from j in _auditService.AuditJobs.IncludeTotalCount()
orderby j.Description
select new
{
JobId = j.ID,
Description = j.Description,
SubscriberCount = j.JobRuns.Count()
};
,如果我不使用j.JobRuns.Count()运行很好,但如果我把它给我得到以下错误:
Constructing or initializing instances of the type <>f__AnonymousType1`3[System.Int32,System.String,System.Int32] with the expression j.JobRuns.Count() is not supported.
这似乎是一个试图通过OData获取嵌套计数的问题。什么是解决这个问题的方法?我试图避免为每个对象获取整个嵌套集合以获得计数。
谢谢!