Click here to Skip to main content
15,436,489 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I want to convert sql query to linq lambda expression syntax

ResultData = db.Students.Include(x => x.Parents)
                   .Include(xx => xx.Trips)
                   .Where(x => x.UserId == User_Id)
                   .Select(x => x.StudentName).ToList();

What I have tried:

select st.Id,StudentName,st.BusId,lat_long,pa.PhoneNumber1,
,pa.PhoneNumber3 image 
from Students st
join Parents pa on pa.Id = st.ParentId
join Trips tr on tr.StudentId=st.Id
where tr.Destination ='home' and tr.BusId =7 
Updated 20-Oct-20 9:39am
Animesh Datta 5-Nov-18 5:05am    
and your problem is ...
NebroProg 5-Nov-18 5:34am    
LINQ code is incorrect
NebroProg 5-Nov-18 5:35am    
I need fully converted SQL to LINQ

Use tool LINQPAD
Share this answer
NebroProg 7-Nov-18 6:28am     CRLF
thank's all the problem in forgen key ,so it was solved
here is the MSFT docs for linq joins

Perform inner joins (LINQ in C#) | Microsoft Docs[^]
Share this answer

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