鑑於下面的數據模型,我想選擇每個具有計劃的ConfigurableItem,其中IsActive = true。在關聯表中選擇
我已經看過很多例子再次:關聯表,並不能真正得到任何人因例子神奇地忽略了許多-to-many關聯。似乎有很多建議,我應該能夠:
var f = from citem in context.ConfigurableItems
where citem.ConfigurableItemSchedules.Schedule.IsActive == true
select citem;
但是,這不智能/編譯。我在這裏錯過了什麼?
UPDATE:
進出口使用從服務器資源管理器(SQL服務器)拖放一個自動生成的.dbml所以下面是一些代碼,是自動生成的,可以幫助回答一些評論。它們只是生成字段的截斷片段。
public partial class ConfigurableItem : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private long _ConfigurableItemIndexCode;
private string _ItemRootPath;
private string _ItemName;
private string _HandlerAssembly;
private string _HandlerType;
private EntitySet<ConfigurableItemProperty> _ConfigurableItemProperties;
private EntitySet<ConfigurableItemSchedule> _ConfigurableItemSchedules;
....
public partial class ConfigurableItemSchedule : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private long _ConfigurableItemIndexCode;
private long _ScheduleIndexCode;
private EntityRef<ConfigurableItem> _ConfigurableItem;
private EntityRef<Schedule> _Schedule;
心不是ConfigurableItemSchedules一採集? – 2013-02-26 08:10:16
你應該使用SelectMany,因爲你有很多行 – 2013-02-26 08:11:59
@Tomas它是一個公共EntitySet ConfigurableItemSchedules –
rism
2013-02-26 08:14:02