C# 如何使用LINQ实现SQL提供的不同连接?
我需要转换此查询:C# 如何使用LINQ实现SQL提供的不同连接?,c#,linq-to-sql,lambda,C#,Linq To Sql,Lambda,我需要转换此查询: SELECT * FROM Table1 AS t1 left join Table2 t2 on t1.Column1 = t2.Column1 left join Table2 t2 on t1.Column2 = t2.Column2 and t2.Column3 = 1 到LinqToSQL和Lambda 我一直在寻找LINQ中SQL连接的良好解释,但没有找到任何明确说明如何利用LINQ实现SQL中提供的不同连接的内容 有人能解释一下如何在SQL中
SELECT *
FROM Table1 AS t1
left join Table2 t2
on t1.Column1 = t2.Column1
left join Table2 t2
on t1.Column2 = t2.Column2 and t2.Column3 = 1
到LinqToSQL和Lambda
我一直在寻找LINQ中SQL连接的良好解释,但没有找到任何明确说明如何利用LINQ实现SQL中提供的不同连接的内容
有人能解释一下如何在SQL中利用不同的SQL联接吗。试试下面的方法:
AlternativeLearningPlanYears
.GroupJoin
(
Leas,
x => x.DistrictLeaId,
y => y.LeaId,
(x,y) => new {x,y}
)
.GroupJoin
(
Leas,
x => new {x.PrivateInstitutionId,1},
y => new {y.PrivateInstitutionId,IsPrivateInstitution},
(x,y) => new {x,y}
)
.Where
(
z => z.x.SchoolYear == 23
&& z.x.Granted == 1
&& z.x.PrivateInstitutionId == null
&& z.x.DistrictName == null
)
我没有你的模式,因此可能会有一些错误,所以请发布它们,我们将解决它们。我在左侧连接上遇到了困难。以下是你的答案: