【发布时间】:2012-03-03 11:50:08
【问题描述】:
您好,希望有人能提供帮助。
我有一个 EF4 上下文,其中包含 2 个基于 POCO 的实体,这些实体映射到旧版 SQL2005 数据库中的 2 个表。表之间没有关系,上下文中的实体定义之间也没有关联。
public class Venue
{
public Venue(){}
public string LocationCode {get;set;}
public string LocationName {get;set;}
}
public class Booking
{
public Booking(){}
public string LocationCode {get;set;}
public int EventReference {get;set;}
public Venue BookingVenue {get;set;}
public Event BookingEvent {get;set;}
}
public class Event
{
public Event(){}
public int EventReference {get;set;}
public DateTime EventStart {get;set;}
/* plus another 60 or so properties */
}
我可以分别从每个选项中进行 LINQ 选择,但每当我尝试在 Event 和 Booking 之间加入时,我都会得到 p>
LINQ to Entities 不支持指定的类型成员“BookingEvent”。仅支持初始化器、实体成员和实体导航属性。
我已经尝试了所有可以在网络上找到的解决方法(没有枚举、计算属性等),现在我有点沮丧。
帮助? 这是有问题的查询....
List<Booking> bookings = (from b in CalendarDB.Bookings
join e in CalendarDB.Events join b.EventReference on e.EventReference
select b).ToList();
【问题讨论】:
-
您能显示相关连接的代码吗?
标签: linq entity-framework join member