相关疑难解决方法(0)

无法比较'System.Collections.Generic.ICollection`1类型的元素仅支持基本类型,枚举类型和实体类型

我写了这段代码

IQueryable<Site> sites = context.MainTable.Include("RelatedTable");

if (!string.IsNullOrEmpty(param1)) {
    sites = sites.Where(s => s.RelatedTable != null && s.RelatedTable.Any(p => p.Name == param1.ToLower() && p.PolicyType == "primary"));
}

foreach (string secondaryPolicy in secondaryPolicies)
{
    sites = sites.Where(s => s.RelatedTable != null && s.RelatedTable.Any(p => p.Name == secondaryPolicy.ToLower() && p.PolicyType == "secondary"));
}

return sites.ToList();
Run Code Online (Sandbox Code Playgroud)

但是ToList在线上我得到了例外

无法比较'System.Collections.Generic.ICollection`1 [[Project1,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null]]'类型的元素.仅支持基本类型,枚举类型和实体类型.

c# linq entity-framework

36
推荐指数
4
解决办法
3万
查看次数

标签 统计

c# ×1

entity-framework ×1

linq ×1