c# - Linq 2 SQL Convert to Outer Join -
i have linq sql query features several joins. want convert 1 of them outer join. problem query has clause. how can convert query use left join on ordercertification table instead of inner join?
the following query did not work (caused app crash):
var ordersummaries = os in dborder.queryordersummaries().where(os => orders.contains(os.orderid)) join o in dc.orders on os.orderid equals o.orderid join oa in dc.orderaddresses on os.orderid equals oa.orderid join d in dc.vdoctors on o.doctorid equals d.doctorid join c in dc.ordercertifications on os.orderid equals c.orderid oc certification in oc.defaultifempty() select new batchorderitem { ordersummary = os, order = o, shipto = oa, prescriber = d, certificationcontact = certification };
the trick using defaultifempty
return rows first table. check out example: http://msdn.microsoft.com/en-us/library/bb397895.aspx
Comments
Post a Comment