I have some earlybound entities built with XrmToolbox, using the IQueryable datasets, trying to extract some Case titles where the Case is not linked to another entity. Tried both of these methods and they produce much the same error:
if (cases.Where(x => !serviceContext.new_casegroupSet.Any(y => y.new_case.Id == x.IncidentId)).ToList().Count() > 0)
{
throw new InvalidPluginExecutionException(OperationStatus.Canceled,
$"Case/s missing Groups: \"{(cases.Where(x => !serviceContext.new_casegroupSet.Any(y => y.new_case.Id == x.IncidentId)).Select(x => x.Title).ToList())}\"");
}
and
if (cases.Where(x => serviceContext.new_casegroupSet.Where(y => y.new_case.Id == x.IncidentId).ToList().Count() == 0).ToList().Count() > 0)
{
throw new InvalidPluginExecutionException(OperationStatus.Canceled,
$"Case/s missing Groups: \"{(cases.Where(x => serviceContext.new_casegroupSet.Where(y => y.new_case.Id == x.IncidentId).ToList().Count() == 0).Select(x => x.Title).ToList())}\"");
}
Error is: Invalid 'where' condition. An entity member is invoking an invalid property or method.
Any of these where I'm not nesting a Where() or an Any() seem to work fine, but Any() doesn't actually seem to work at all.
Is this even possible? Or do I have to get the Cases first and iterate through them for matches in the linked entity?