【发布时间】:2015-05-05 03:04:47
【问题描述】:
我正在做 2 个 linq 查询,一个是实体框架,另一个是 linq to sql,它们根本不能很好地配合使用。
第一个查询通过实体框架获取一个表中的 id。
var pemdata = from pd in db.tblMap
where pd.PID == pid
select new
{
eid = pd.EID
};
然后我使用包含通过 linq to sql 过滤第二个查询。
var data = from e in p.entities
join et in p.entity_types on e.entity_type equals et.entity_types_id
where pemdata.Contains(e.entity_id)
select new gEntities
{
entity_type = e.entity_type.ToString(),
Name = e.entity_name,
Type = et.entity_types_name,
Address = e.entity_address,
City = e.entity_city,
Zip = e.entity_zip.ToString()
};
我看到的问题是一个错误。
实例参数:无法从 'System.Linq.IQueryable' 转换为 'System.Linq.ParallelQuery'
'System.Linq.IQueryable' 不包含 'Contains' 的定义和最佳扩展方法重载 'System.Linq.ParallelEnumerable.Contains(System.Linq.ParallelQuery, TSource)' 有一些无效参数
我通常不会遇到这样的问题。但是当我将 linq 混合到 sql 和实体框架时,我遇到了这个问题。
有什么想法吗?
【问题讨论】: