【发布时间】:2012-03-04 17:07:42
【问题描述】:
我在 LINQ to SQL 中有一个有效的查询。我需要将其转换为 LINQ to Entities。
(from pr in Products
join c in Categories on pr.CategoryID equals c.CategoryID
join b in Colors on pr.ColorID equals b.ColorID
select new{
ProductID = pr.ProductID,
Manufacturer = pr.Manufacturer.Name,
Model = v.Model.ModelName,
Category = c.Name,
Photos = from p in Photos where pr.ProductID == p.ProductID select p
}).FirstOrDefault()
当我按原样使用它时,我得到一个错误:
无法创建类型只有原始类型的常量值('例如 在此上下文中支持 Int32、String 和 Guid')。
问题出在这部分:
Photos = from p in Photos where pr.ProductID == p.ProductID select p
【问题讨论】:
标签: linq-to-entities