Click here to Skip to main content
14,827,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 2-Sep-20 0:08am

Linqer is a SQL to LINQ converter tool. It helps to learn LINQ and convert raw SQL statements to LINQ. Linqer supports both .NET languages - C# and Visual Basic. Follow below link to download the tool:

Linqer[^]
   
v2
Comments
Member 14849037 2-Sep-20 6:10am
   
select count(SampleTypeCollections.id) as sampleCount from SampleTypeCollections
WHERE sampletypecollections.id in (select SampleId from SampleTest
join SampleTestDiseases on SampleTestDiseases.SampleTestId = SampleTest.id
join SampleTestPerformed on SampleTestPerformed.sampletestid = sampletest.id
where SampleTest.SampleId = sampletypecollections.id and SampleTestPerformed.TestResultId = 2
and(SampleTypeCollections.CreateDate BETWEEN to_date('9/9/2020' , 'dd/mm/yyyy') AND to_date('9/2/2020', 'dd/mm/yyyy')))
Try this linq 101

101 LINQ Samples in C#[^]
   
select count(SampleTypeCollections.id) as sampleCount from SampleTypeCollections 
                 WHERE  sampletypecollections.id in (select SampleId from SampleTest 
                 join SampleTestDiseases on SampleTestDiseases.SampleTestId = SampleTest.id 
                 join SampleTestPerformed on SampleTestPerformed.sampletestid = sampletest.id 
                 where SampleTest.SampleId = sampletypecollections.id  and SampleTestPerformed.TestResultId = 2 
                 and(SampleTypeCollections.CreateDate BETWEEN to_date('" + FirstDate.ToShortDateString() + "' , 'dd/mm/yyyy') AND to_date('" + ToDate.ToShortDateString() + "', 'dd/mm/yyyy')))");
   
Comments
Maciej Los 2-Sep-20 6:31am
   
I doubt that OP is interested in an answer after over 4 years...

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