我有如下三张表没有关联
- 客户
- 银行
- 国家
一些客户他们没有银行详细信息,所以我需要获取所有的客户信息,谁有银行,谁没有银行,以及国家信息
我知道这是“左外连接”方法。它如何在 Linq to sql 中使用
vb.net代码请
最佳答案
var query =
from order in dc.Orders
from vendor
in dc.Vendors
.Where(v => v.Id == order.VendorId)
.DefaultIfEmpty()
from status
in dc.Status
.Where(s => s.Id == order.StatusId)
.DefaultIfEmpty()
select new { Order = order, Vendor = vendor, Status = status }
//Vendor and Status properties will be null if the left join is null
关于c# - Linq to sql - 左外连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3633444/