鉴于这种LINQ查询如何获得LINQ查询
from c in context.Customers
from o in c.Orders
where c.City == "MyCity" || o.ShipTo == "MyCity"
select c
如果客户的城市是“MyCity”,但没有任何订单的查询将不会返回任何行外连接。这是因为客户和订单之间隐含的内部联接。如何选择“MyCity”城市的客户或订单发货到“MyCity
在这种情况下,我需要一个客户和订单之间的外部连接,我如何在Linq中表达?我认为大致的TSQL是
select customers.*
from customers
left join orders on customers.id = orders.customerid
where customers.city = 'MyCity' or orders.ShipTo = 'MyCity'
是它们产生相同的SQL。我喜欢第二种选择的样子。谢谢。 – 2010-10-20 14:51:11