【发布时间】:2013-03-13 14:10:22
【问题描述】:
我正在使用 LinqPad 来测试我的查询。此查询在 LInqPad 连接到我的数据库(LInq 到 SQL)时有效,但当我将连接更改为使用我的 Entity Framework 5 Model.dll 时它不起作用。 (链接到实体)。这是在 C# 中。
我有两个名为 Plan 和 PlanDetails 的表。关系是一个计划对多个计划细节。
var q = from pd in PlanDetails
select new {
pd.PlanDetailID,
ThePlanName = (from p in this.Plans
where p.PlanID == pd.PlanID
select p.PlanName)
};
var results = q.ToList();
q.Dump(); //This is a linqpad method to output the result.
我收到此错误“NotSupportedException:无法创建类型为“Domain.Data.Plan”的常量值。在此上下文中仅支持原始类型或枚举类型。”任何想法为什么这只适用于 Linq to SQL?
【问题讨论】:
标签: linq c#-4.0 linq-to-sql linq-to-entities entity-framework-5