none
LINQ with Inner and Left Outer Join RRS feed

  • Question

  • Can someone help me with this conversion. I'm pulling my hair out.

    This work perfect on SQL server but I need the exact same thing in LINQ so my application can us it.

    Obviously I got few parameters to pass as well.

    Thank you very much.

    SELECT Table_RR.*
    FROM   Table_S 
    INNER JOIN Table_RR ON Table_S.Id = Table_RR.s_Id 
    LEFT OUTER JOIN Table_R 
    LEFT OUTER JOIN Table_FBT 
    INNER JOIN Table_RF 
    ON Table_FBT.Id = Table_RF.FBT_Id 
    ON Table_R.Id = Table_RF.R_Id 
    ON Table_RR.RF_Id = Table_RF.Id
    WHERE (Table_RF.FBT_Id = N'eac0b83b-be74-429c-ae30-1fae1d861e6c') AND (Table_RF.FT = 1) AND (YEAR(Table_R.EventDate) = 2017) AND (Table_R.O_Id = N'a28fab7b-49f1-40b5-8af7-2d5a72a177f0') AND (Table_RF.isPF = 1)
    ORDER BY Table_R.EventDate Desc

    Wednesday, October 11, 2017 8:20 PM

All replies

  • Hello hobie1,

    According to your question is more related to linq to sql , I will move the thread to Linq to Sql Forum  for suitable support.There are a lot of experience people that could help you hand the problem.

    The Visual C# discuss and ask the C# programming language, IDE, libraries, samples and tools . If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution .

    Sincerely,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by hobie1 Thursday, October 12, 2017 3:15 AM
    • Unmarked as answer by hobie1 Thursday, October 12, 2017 3:22 AM
    Thursday, October 12, 2017 2:16 AM
  • Hi,

    I have no schema of your table. It looks like as below.

        var query = from o in db.Orders
                                join od in db.Order_Details on o.OrderID equals od.OrderID //inner join
                                join c in db.Customers on o.CustomerID equals c.CustomerID into co //outer join
                                from t in co.DefaultIfEmpty()
                                join e in db.Employees on o.EmployeeID equals e.EmployeeID into eo //outer join
                                from z in eo.DefaultIfEmpty()
                                join et in db.EmployeeTerritories on z.EmployeeID equals et.EmployeeID
                                where (o.EmployeeID==1)
                                orderby o.Freight descending
                                select o;

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 16, 2017 2:01 PM