0

I am new to Linq, and I need to convert this query to a left outer join between DocumentStores and Orders, as not all documents are related to an order:

    var documents=(from d in _dataContextOrders .DocumentStores 
                           join o in _dataContextOrders.Orders on d.OrderID equals o.ID
                           join t in _dataContextOrders .DocumentTypes on d.DocumentType equals t.DocTypeID
                       select new
                           {
                               d.ID,
                               o.PORef ,
                               t.DocTypeDescription,
                               d.Name,
                               d.ContentType
                           }).ToList();

How do I achieve this?

2

1 Answer 1

1
from a in dataContext.<tableA>
join _b in dataContext.<tableB> on a.id equals _b.aid into _b
from b in _b.DefaultIfEmpty()
select <whatyouwanttoselect>

b will be null, if the join on the ids fails

Not the answer you're looking for? Browse other questions tagged or ask your own question.