Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
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'


[link to TV/Movie collection has been removed]

What I have tried:

I have tried for online tool to convert query from sql to linq but didnt succeed.
Posted
Updated 29-Dec-22 7:24am
v2
Comments
Afzaal Ahmad Zeeshan 15-Jan-22 19:22pm    
I would keep this query in SQL for performance reasons and map the records/results to C# instead. :-)

See LINQ to SQL example here: Getting Started - ADO.NET | Microsoft Docs[^]
 
Share this answer
 
Comments
Maciej Los 16-Jan-22 3:39am    
5ed!
 
Share this answer
 
Found couple of tools in the below msdn social comments section

Try
1. LINQPad - The .NET Programmer's Playground

2. Linqer | SQL to LINQ converter

Hope this helps.

My personal opinion - try a Stored Procedure rather than a complicated LINQ query. That would be way easier to manage and trouble shoot and more more efficient if it is fetching bulk data.
 
Share this answer
 
Comments
Graeme_Grant 29-Dec-22 23:53pm    
This was already answered and accepted back in January. Please stick to current questions where help is needed.
Vivek_Dutta 30-Dec-22 12:35pm    
Thank you Grant. I just shared because I found the more recent and improved solution. I will stick to new questions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900