What is the syntax for an inner join in LINQ to SQL?

后端 未结 19 1634
感情败类
感情败类 2020-11-22 04:25

I\'m writing a LINQ to SQL statement, and I\'m after the standard syntax for a normal inner join with an ON clause in C#.

How do you represent the follo

19条回答
  •  长发绾君心
    2020-11-22 04:58

    OperationDataContext odDataContext = new OperationDataContext();    
            var studentInfo = from student in odDataContext.STUDENTs
                              join course in odDataContext.COURSEs
                              on student.course_id equals course.course_id
                              select new { student.student_name, student.student_city, course.course_name, course.course_desc };
    

    Where student and course tables have primary key and foreign key relationship

提交回复
热议问题