i have a 3 class models with overlapping relationships:
class worder {
int workerID
}
class shift {
int shiftID,
int workerID,
ICollection tasks //tasks for this shift and this worker
}
class task {
int workerID
int shiftID
}
how do i populate a collection of shift objects that include its respective .tasks? something like:
var q = from shift in db.shifts
.Include(s => s.tasks.Where(t=>t.shiftID == s.shiftID && t.workerID = s.workerID))
EDIT
I have successfully used an projection to create an anonymous type as suggested by jethro. but i would like to return strongly typed shift classes instead. is that possible? or a poor design of the shift model?
You can join the tables.
Please check this Link for additional examples on Linq Joins.
Something about the above feels “not right” to me, I think it would be best if you look at your design again, the tasks of the shifts should be populated automatically when you pull the shifts.