0
我在写一个linq查询时遇到了一些麻烦。在一个linq查询中使用.Contains返回一个SystemException
我有列表A的产品已被修改,所以我试图从数据库中获取产品列表,以允许我应用更改。
我试图2个不同的查询
var query = from p in db.Products
where products.Select(z => z.id).Contains(p.Id)
select p;
var query2 = from p in db.Products where (from o in products
select o.id)
.Contains(p.Id)
select p;
两种尝试返回错误
基{System.SystemException} = {“无法创建类型的恒定值“ProjectABC.Models .ProductModel'。在这种情况下,只支持原始类型(如Int32,String和Guid)。“}
我在做什么错?
感谢约阿希姆的作品。 – 2012-02-04 22:31:36