问题描述
请朋友帮我转发下面的SQL查询到linq。
选择b.DISTRICT,b.TEHSIL,b.UID,b.BeneficiaryFullname,b .BeneficiaryRationCardID,b.Gender
来自
(
选择BeneficiaryRationCardID,min(DOB)为MaxAge
来自BPLFamilyDetails其中gender ='F'
group by BeneficiaryRationCardID
)a
内部联接BPLFamilyDetails b on a.BeneficiaryRationCardID = b.BeneficiaryRationCardID and a .MaxAge = b.DOB
内部加入
(
选择x.BeneficiaryRationCardID
来自BPLFamilyDetails x
左连接(从BPLFamilyDetails中选择BeneficiaryRationCardID,其中UID为空)y on x.BeneficiaryRationCardID = y.BeneficiaryRationCardID
其中y.BeneficiaryRationCardID为null
group by x.BeneficiaryRationCardID
)c on a.BeneficiaryRationCardID = c.BeneficiaryRationCardID
其中b.Gender ='F'
我尝试了什么:
我试过在线工具将查询从sql转换为linq但没有成功。
请帮我解决这个问题。
Please any buddy help me to convert below sql query to linq.
Select b.DISTRICT,b.TEHSIL,b.UID,b.BeneficiaryFullname,b.BeneficiaryRationCardID, b.Gender
from
(
select BeneficiaryRationCardID, min(DOB) as MaxAge
from BPLFamilyDetails where gender='F'
group by BeneficiaryRationCardID
) a
inner join BPLFamilyDetails b on a.BeneficiaryRationCardID=b.BeneficiaryRationCardID and a.MaxAge=b.DOB
inner join
(
select x.BeneficiaryRationCardID
from BPLFamilyDetails x
left join (select BeneficiaryRationCardID from BPLFamilyDetails where UID is null) y on x.BeneficiaryRationCardID=y.BeneficiaryRationCardID
where y.BeneficiaryRationCardID iS null
group by x.BeneficiaryRationCardID
) c on a.BeneficiaryRationCardID=c.BeneficiaryRationCardID
where b.Gender='F'
What I have tried:
I have tried for online tool to convert query from sql to linq but didnt succeed.
please help me to get out of this.
推荐答案
这篇关于如何使用c#将sql查询转换为linq?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!