Given the data model below I would like to select every ConfigurableItem that has a Schedule where IsActive =true.
I have looked at numerous examples re: associative tables and don't really get any of them due to the examples somehow magically ignoring the many-to-many association. There seems to be a lot of suggestion that I should be able to :
var f = from citem in context.ConfigurableItems
where citem.ConfigurableItemSchedules.Schedule.IsActive == true
select citem;
But that doesn't intellisense / compile. What am I missing here?
UPDATE:
Im using a .dbml autogenerated from drag and drop from server explorer (sql server) so below is some code that is auto generated that may help answer some of the comments. They're just truncated snippets of the generated fields.
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;
I think you need:
var f = from citem in context.ConfigurableItems
where citem.ConfigurableItemSchedules.Any(s=>s.Schedule.IsActive)
select citem;
or something like that.