score:1
Accepted answer
Something like this maybe:
var listC = (
from hb in holdBilling
from p in payer.Where(a=>a.payerID==hb.payerID).DefaultIfEmpty()
from c in carrier.Where(a=>a.carrierID=hb.carrierID).DefaultIfEmpty()
where hb.bEntityID==378
select new
{
hb.bEntityID,
c.carrierID,
c.carrierName,
p.payerID,
p.payerName,
holdType=(payer==null?"P":"C")
}
).Take(1000)
.ToList();
score:1
You need to use DefaultIfEmpty to do a left join
var listC = (from hold in holdBilling
from u in Users.Where(x => hold.createUserID == x.userID).DefaultIfEmpty()
from c in carrier.Where(x => hold.carrierID == x.carrierID).DefaultIfEmpty()
select new
{
Elem = hold,
FName = u.userFirstName,
LName = u.userLastName,
Carrier = c.carrierName,
Payer = ""
}).ToList();
Source: stackoverflow.com
Related Articles
- Doing 2 Left Joins on the same table with one call
- LINQ MVC ViewModel: Multiple joins to the same table with optional field
- Multiple joins to the same table with the Entity Framework
- Convert SQL with multiple joins (with multiple conditions) of the same table to LINQ
- LINQ left join with count - multiple table joins Visual Studio 2015 MVC 5 C#
- Linq to NHibernate generating multiple joins to the same table
- LINQ - Multiple left joins with nullable values
- Entity Framework generating LEFT OUTER JOINs when it should be doing INNER JOINs (multiple tables)
- Map class to tables with different table names but same column structure
- How to perform left join in linq having multiple table joins
- Multiple outer join using Linq with 2 joins to the same table/object. Got the SQL, need the Linq to Entity
- Convert SQL statement to Linq Statement (3 table left joins + where)
- Left Outer Joins with Linq extension methods?
- how do you chain left joins with a lambda
- left join with up to one row in the right table in LINQ
- LINQ to Entities - Multiple Joins on Same Table
- Linq to entities query with nested query on the same table
- EF4.2 extra left outer join to same table
- LINQ multiple joins with one left join
- Complex joins in Linq with multiple tables and LEFT OUTER JOIN
- Distinct rows from db table with unique IDs but same names
- Left Join 2 tables with main table using LINQ
- multiple left joins with Linq
- EF Core difficulty with INNER JOINS and LEFT JOINS
- How to convert a SQL with multiple left joins to an Entity Framework LINQ statement using Include methods (No Join methods)?
- Converting SQL Statement with Multiple Left Outer Joins and Various Clauses to LINQ
- SQL to Linq query with multiple left outer joins
- LINQ to SQL: Left join a table with itself and compute an average
- SQLite DB: Create a SQL Statement with LINQ that uses the same table twice but without CROSS JOIN
- Left join two tables with a default value when no match is found in the right table
- How to concatenate different row collections with LINQ?
- handling empty strings using linq
- Why does not entity framework use the like in this LinQ subquery?
- How to resolve issue: "At least one object must implement IComparable."
- LINQ statement to find the max amount days using datetime
- Using LINQ with NHibernate
- If statement not returning value in razor
- How to create dynamic Linq Select Expression with anonymous objects
- Why is Entity Framework generating a JOIN on SELECT
- Building custom where clause with dynamic column input LINQ
- Children could not be evaluated
- Linq List Contains
- Generating expression tree for a subproperty test
- Get item from database result by using entity framework linq
- How can I invoke several clients' async methods and aggregate the results into one task generically?
- HTML.DropDownListFor - Syntactic Sugar for SelectList
- Querying complex data types in EF Core with LINQ
- c# lambda expression convert from vb to c#
- Counting Word Frequency (most significant words) in a String, excluding keywords
- Read then write html to xml file using linq xml and xml writer