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 Query
- Doing 2 Left Joins on the same table with one call
- LINQ MVC ViewModel: Multiple joins to the same table with optional field
- left join with up to one row in the right table in LINQ
- Multiple joins to the same table with the Entity Framework
- Convert SQL with multiple joins (with multiple conditions) of the same table to LINQ
- how to copy one column data to another column with in the same table using linq?
- Left join on two Lists and maintain one property from the right with Linq
- Merge two Lists in C# and merge objects with the same id into one list item
- Linq to NHibernate generating multiple joins to the same table
- C# LINQ Select objects with the same value of one property join values of other
- Which one is better for getting the last row of my table with linq to nhibernate?
- Multiple outer join using Linq with 2 joins to the same table/object. Got the SQL, need the Linq to Entity
- combine 2 queries from the same table into one linq query
- VB.Net Linq with datatables - select from one table what does not exist in the other
- Linq to entities query with nested query on the same table
- C# Linq with datatables - select from one table what does not exist in the other
- One liner for concatenation of two different lists of objects with the same interface
- LINQ multiple joins with one left join
- Create one List from several different lists of the same type with C#
- How do I join more than one files, in a Linq (C#) where one of the joins is a left join
- 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
- Linq query on the same table with difference between rows
- C# and ADO .NET entity data models with LINQ associations and entities for the same table
- How to remove strings with the same length except one in LINQ?
- Is there a way that I can set more than one property in a list to "" or null at the same time with a .ForEach?
- How does EF create the SQL needed to update one million rows in a SQLite table with five million rows? Does it do one by one row updates?
- Comparing 2 lists of chars with binary digits, with aim to replace every 0 by 1 in the first list if in the other one has on the same place 1
- one to many relationship in Entity Framework on the same table
- multiple joins in LINQ Query with 3 tables on the same column
More Query from same tag
- Filter JSON by key name using LINQ
- C# - filtering collection based on another collection exception
- Dictionary ForAll / ForEach method
- Linq to RSS feed?
- How to sort an internal List<myObject>
- how to get all columns from a linq result with a join
- Select more then one node from XML using LINQ
- How to write LINQ query that selects a property which is a string concat of a collection of a nested entity properties?
- How can i convert a SQL query into LINQ using group and having?
- skip multiple values in foreach loop
- Group dictionary by multiple properties of key
- How do I write SELECT FROM myTable WHERE id = (SELECT) in Linq?
- Improve performance of getting distinct items
- How can I remove all instances of a string within a string inside a list?
- How do I search just the children of an XDocument, rather than all of its descendants?
- Outer Join is not working in Linq Query: The method 'Join' cannot follow the method 'SelectMany' or is not supported
- Using lambda or linq driven query to get a WCF paged result
- How to get a float array from a List of 3 doubles?
- Creating an anonymous object via LINQ from IObservable?
- How to write a LINQ query or Lambda expression on one to many relation with filter
- LINQ or REGEX to extract certain text from a string
- Using Large Arrays in VB.NET
- Using lambda to select top 1 row returned from DataTable
- Implicitly convert collection (HashSet) to IEnumerable<T>
- Unable to read XML correctly
- Linq query no longer ordered properly after .Distinct() used
- Migrating vs2008 to vs2012 - Exception LINQ to SQL Library
- Getting a single result from a LINQ statement
- Left Outer Join in Linq to Entities / SQL
- Expression to find all objects that contain all elements in an array of integers