Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个具有表连接和几个表内部连接的 Linq 查询。有时,当表为空时,我会从查询中得到错误。我想做的是即使其他表为空,我也试图从表中获取值。
提前致谢。
你需要做左连接假设客户和订单表之间的左连接。
var query = from customer in dc.Customers from order in dc.Orders .Where(o => customer.CustomerId == o.CustomerId) .DefaultIfEmpty() select new { Customer = customer, Order = order }
另请参阅以下链接 http://forums.asp.net/t/1792428.aspx/1