LINQ 中的外连接问题
我想使用此查询中的第二个连接语句执行外连接,但我不断收到奇怪的错误! (它必须是第三个红牛)
var Objeto = from t in Table1.All()
join su in table2.All() on t.Id equals su.Id
join tab2 in Table1.All() on t.PId equals tab2.Id //<-I want it here
select new
{
t.Field1,
SN = su.Field123,
PTN = tab2.FieldABC
};
任何帮助将不胜感激。
[编辑] - 我忘了说我正在使用 SubSonic 3.0,这个错误似乎与 SubSonic 相关......
Id like to perform an outer join with the second join statement in this query, I keep getting weird errors! (it must be the 3rd RedBull)
var Objeto = from t in Table1.All()
join su in table2.All() on t.Id equals su.Id
join tab2 in Table1.All() on t.PId equals tab2.Id //<-I want it here
select new
{
t.Field1,
SN = su.Field123,
PTN = tab2.FieldABC
};
Any help would be appreciated.
[Edit] - I neglected to say that I'm using SubSonic 3.0, the bug seems to be with SubSonic.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行外连接需要两个步骤: 使用
into
将连接转换为组连接DefaultIfEmpty()
生成null
值您期望连接的结果集是否为空。您还需要向
select
添加null
检查。Performing an outer join requires two steps:
into
DefaultIfEmpty()
on the group to generate thenull
value you expect if the joined result set is empty.You will also need to add a
null
check to yourselect
.