Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
SELECT c.* , v.*
  FROM UserEnrolleds u
  INNER JOIN Courses c ON u.CourseId = c.id
  INNEr JOIN Videos v ON v.CourseID = c.Id
  WHERE u.UsersID = '8851d572-eaff-4a84-9ec8-aa144fecfea2'


What I have tried:

please help me this how to convert sql to linq
Posted
Updated 10-Sep-19 23:43pm
Comments
F-ES Sitecore 11-Sep-19 5:00am    
google "linq join", this is extensively documented.
tyson Hamda 11-Sep-19 5:23am    
I did but the problem is I never work with these LINQ Statements before. So if you or anyone can convert this query for me. Thanks
jimmson 11-Sep-19 5:43am    
There's always the first time for everybody. Better start learning ;)

1 solution

You can do something like this
C#
var resultList = (from u in context.UserEnrolleds
	join c in context.Courses on u.CourseId equals c.Id
	join v in context.Videos on v.CourseId equals c.Id
    where u.UserId == "8851d572-eaff-4a84-9ec8-aa144fecfea2"
	select new { 
           CourseName = c.CourseName, 
           VideoUrl = v.Url, 
           .......
           ......
        }).ToList();


C#
select new
'll give you anonymous type then you can map it to data transfer object.
Or map it at the same time like
C#
select new CourseVideoDto {
 
Share this answer
 
v2

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