Posted on 2011-10-25
Last Modified: 2013-11-11
I am trying to get LEFT JOIN in LINQ. For some reason it works as INNER JOIN. Can you please help me with this query ?
            var qry = from i in tbcharges
                      join fo in tbfotranslation on i.ChargeDesc equals fo.CCSubcontractorName
                      where i.Reconciled==false
                      select new {i.ChargeAmt, i.ChargeDate, i.ChargeDesc, i.Comments, i.CreditCardNo, i.FileName, i.RecId, i.Reconciled,  OdyFoCode= fo !=null ? fo.OdySubcontractorCode : "" };
Question by:crcsupport
    LVL 14

    Accepted Solution

    if i remember correctly, you need to use the IN keyword.  

    var LeftJoin = from emp in ListOfEmployees
    join dept in ListOfDepartment
    on emp.DeptID equals dept.ID into JoinedEmpDept 
    from dept in JoinedEmpDept.DefaultIfEmpty()
    select new                          
    EmployeeName = emp.Name,
    DepartmentName = dept != null ? dept.Name : null                          

    Open in new window

    LVL 1

    Author Closing Comment

    thank you

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    This video discusses moving either the default database or any database to a new volume.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now