Here is the query I am trying to run from my OData source:
var query = from j in _auditService.AuditJobs.IncludeTotalCount()
orderby j.Description
select new
{
JobId = j.ID,
Description = j.Description,
SubscriberCount = j.JobRuns.Count()
};
It runs great if I don't use the j.JobRuns.Count(), but if I include it I get the following error:
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.
It seems to be a problem of attempting to get the nested count through OData. What is a work around for this? I was trying to avoid getting the whole nested collection for each object just to get a count.
Thanks!