Let's say I have these two tables:
ParentDataItem
ParentDataItemID
...some other fields...
ChildDataItem
ChildDataItemID
ParentDataItemID (foreign key)
Name
Value
Now I want to select any ParentDataItems that have a ChildDataItem with a specified name and value.
I know I was way off with my first approach, which was something like:
// db is the data context object
db.ParentDataItems.Where(p => p.ChildDataItems.Where(c => c.Name == "XXX" && c.Value == "XXX"));
I prefer lambda syntax but either would do.