我有一些使用 XrmToolbox 构建的早期绑定实体,使用 IQueryable 数据集,试图提取一些案例标题,其中案例未链接到另一个实体。尝试了这两种方法,它们产生了几乎相同的错误:
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())}\"");
}
和
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())}\"");
}
错误是:Invalid 'where' condition. An entity member is invoking an invalid property or method.
我没有嵌套 Where() 或 Any() 的任何这些似乎都可以正常工作,但 Any() 实际上似乎根本不起作用。
这甚至可能吗?还是我必须先获取案例并遍历它们以在链接实体中进行匹配?