【发布时间】:2017-05-20 19:04:46
【问题描述】:
我有这样的查询
IEnumerable<int> companies = Employers
.Where(p => p.Id == User.ID
.SelectMany(p => p.companies)
.Select(p => p.Id);
return Employers
.Where(p => companies.Contains(p.Companies)
.Include(p => p.FirstName)
.ToList();
这里p.Companies指的是
Public Virtual List<Company>
在Employers 类下。
出现此错误:
“IEnumerable”不包含“Contains”的定义,最佳扩展方法重载“Queryable.Contains>(IQueryable>,List)”需要“IQueryable>”类型的接收器
【问题讨论】:
-
搜索网络。这个问题已经被问过很多次了。错误信息非常清楚。您需要将 IQuertable 添加到类对象中。
-
我是实体框架的新手。我找不到解决方案。请有人帮我找到解决方案。谢谢
标签: c# linq entity-framework-4