• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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