我有数据库
Table room: id,name
Table table: id, id_room
Table WorkPanel: id, id_table, **date**.
我使用(date == date,而WorkPanel有表记录):
var nowWorkPanels = from a in context.WorkPanels where a.date == date select a;
但是我不知道如何在那个时候进行检查,并且在这个房间里有一个记录
答案 0 :(得分:1)
您显然没有显示表格中的所有字段,但如果您的导航属性设置正确,您的查询将如下所示:
from wp in context.WorkPanels
where wp.date == date && wp.Table.id_room == roomId
select wp;
或者如果您想按房间名称查询:
from wp in context.WorkPanels
where wp.date == date && wp.Table.Room.name == roomName
select wp;
我更喜欢使用更简洁的方法链接语法:
context.WorkPanels.Where(wp => wp.date == date && wp.Table.id_room == roomId);