Sak*_*o73 3 linq linq-to-objects linq-to-entities entity-framework
我有以下表结构已导入到实体框架中.我需要编写一个LINQ查询,我在其中选择Table1的实体,其中Table2中的字段等于true,表3中的字段等于特定的GUID.
有人可以帮忙吗?
谢谢.
尝试:
from t3 in dataContext.Table3
where t3.Guidfield == someGuid
from t2 in t3.Table2
where t2.Field // boolean field is true
select t2.Table1;
Run Code Online (Sandbox Code Playgroud)
编辑:根据要求,等效的lambda表达式语法:
dataContext.Table3.Where(t3 => t3.Guidfield == someGuid)
.SelectMany(t3 => t3.Table2)
.Where(t2 => t2.Field)
.Select(t2.Table1);
Run Code Online (Sandbox Code Playgroud)