Converting SQL Statement to LINQ

57 Views Asked by At

I am working on ASP.Net MVC4 application with EF , I am working to write my queries . I still exploring linq !

This is my SQL Statement : where I have 7 table to make join between them :: Date , Student, Task, Timing , Assign ,SousType,TypeT

select  type ,  from Date , Student, Task,  Timing , Assign ,SousType,TypeT 
where DateT.ID_Date=Timing.ID_Date and Timing.ID_Timing = Assign.ID_Assign and Assign.ID_Student=Student.ID_Student 
and Assign.ID_Task= Task.ID_Task and Task.ID_SousType = SousType.ID_Sousype and SousType.ID_TypeT = TypeT.ID_Type ;

I started converting it step by step , but I could go further ,

   var students = from s in db.student
                      select s;
   IQueryable<Assign> mylist = db.Assign.Where(s => s.ID_Student == students.ID_student);

But I couldn't keep dealing in the same way to verify ID of every table since I got " IQueryable " .

Am I in the right way !!

1

There are 1 best solutions below

3
Yvo On BEST ANSWER

Check out LINQ 101, there's a dedicated join operator: http://code.msdn.microsoft.com/LINQ-Join-Operators-dabef4e9