score:2
Accepted answer
Try below code
var summaryPayments = (from s in paymentsList
join alloc in allocationList on s.ID equals alloc.OriginalID into allocOrg
from po in allocOrg.DefaultIfEmpty()
join allocRev in allocationList on s.ID equals allocRev.ReversalID into allocRevs
from pr in allocRevs.DefaultIfEmpty()
select new { s, pr }).Select(x => { x.s.ReversalId = (x.pr != null ? x.pr.ReversalID : 0); return x.s; });
Source: stackoverflow.com
Related Articles
- How to prepopulate projection result with existing left model in linq left join query
- Linq problem when trying a left join projection with multiple records
- Populating a model with a LINQ outer join result
- Left outer join Linq to Entities with MVC model
- Join an array of string with the result of an existing linq statement
- LINQ to SQL - Left Outer Join with multiple join conditions
- Convert SQL to Linq left join with null
- How do I most elegantly express left join with aggregate SQL as LINQ query
- Linq - Left outer join with dot notation
- Left join on two Lists and maintain one property from the right with Linq
- Linq-to-Entities: LEFT OUTER JOIN with WHERE clause and projection
- How to left join multiple tables with LINQ
- Linq with Left Join on SubQuery containing Count
- Left outer join using LINQ -- understanding the code
- Linq left outer join with custom comparator
- JOIN and LEFT JOIN equivalent in LINQ with Method Syntax
- LINQ left join with only the row having maximum value of a column
- how to get all columns from a linq result with a join
- Using LINQ left join with multiple conditions and subquery
- SQL to LINQ with multiple join, count and left join
- LInq left join with multiple condition in on clause
- Left join with OrderBy in LINQ
- LINQ Left Outer Join combined with Let
- Left outer Join with LINQ
- LINQ & Enum with Left Join
- How make LINQ query with GroupBy and LEFT JOIN
- LINQ to Sql Left Outer Join with Group By and Having Clause
- Multiple Join Statements with LEFT JOIN to LINQ Expression syntax
- Entity Framework: How to perform left join with EF and LINQ among multiple tables
- Converting a LINQ Inner join with Left Join
- truncate text using linq
- Complex LINQ or EF query
- WPF TreeView Binding
- LINQ query not returning the correct result
- Split and get last part of a string in c#
- How to find the next element in a generic List?
- LINQ to Entities does not recognize the method 'System.DateTime ParseExact(System.String, System.String, System.IFormatProvider)' method error in MVC5
- Understanding how to make repository queries asynchronous
- False "Sequence contains no elements" exception when using Single()
- Delete multiple XML nodes in C# using Linq
- Dynamic LINQ function using dictionary as a Parameter to filter method
- joining two linq results which is not of same type using linq
- trim away duplicates using Linq
- How to convert store procedure to linq in nopCommerce c#
- Smart sorting by release date and version
- Select most recent row filtered on multiple columns
- LINQ-query select statement before order by or vise versa is better
- How to get the most recent created subdirectory by using linq?
- EF Core Group On Nav Properties
- Is there a neater linq way to 'Union' a single item?