0
首先,我的表設置:實體框架 - 如何基於橋表值查詢對象?
Group:
groupId - int
groupName - varchar
Schedule:
scheduleId - int
scheduleName - varchar
Group_Schedules
scheduleId - int/fk to Schedule
groupId - int/fk to Group
我使用的是EF,在上述情況下,沒有創建EF實體代表Group_Schedules,而是一個集合添加到組和日程安排表代表其他結束。
我需要得到屬於一個時間表的所有組,並讓我的回報爲IQueryable<Group>
。即(不,這不會因爲EF產生橋接表的工作方式):
var g = from g in context.Groups
where g.Group_Schedule.scheduleId = 1 // This doesn't work because Group_Schedule is a collection of Schedule
select g;
有一種優雅的方式來獲得我所需要的數據?