• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

JOIN in LINQ

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 : "" };
0
crcsupport
Asked:
crcsupport
1 Solution
 
binaryevoCommented:
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

0
 
crcsupportAuthor Commented:
thank you
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now