Click here to Skip to main content
14,300,872 members
Rate this:
Please Sign up or sign in to vote.
See more:
SELECT c.* , v.*
  FROM UserEnrolleds u
  INNER JOIN Courses c ON u.CourseId =
  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
Updated 10-Sep-19 23:43pm
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can do something like this
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, 

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

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100