【发布时间】:2014-08-07 23:21:54
【问题描述】:
我在 EntityModel 中有 3 个实体:Customer、CustomerAddress(这是具有 Ids 和 orderOnControl 列的连接实体,不能在模型中省略)和 Address。我需要使用地址对 FULL JOIN 客户进行 linq 查询。 SQL 中的这个查询很简单:
select e1.[AddressID], e1.City, e3.CustomerID, e3.LastName from [SalesLT].[Address] as e1
full join [SalesLT].[CustomerAddress] as e2 on e1.[AddressID] = e2.[AddressID]
full join [SalesLT].[Customer] as e3 on e2.CustomerID = e3.CustomerID
但我需要用 linq 写这个,我找到了有 2 个实体具有多对可能关系的答案,但找不到任何具有连接实体的实体,我将不胜感激任何提示
【问题讨论】:
-
FULL JOIN?你确定吗? -
是的,我需要完全连接(结果将用作控制数据源,我可以在其中选中复选框以连接行元素)。我认为“LINQ - Full Outer Join”是两个表的不同场景。
-
您可以应用两表解决方案两次以获得 3 表全外连接。