C# Linq完全外连接

C# Linq完全外连接,c#,entity-framework,linq,linq-to-sql,C#,Entity Framework,Linq,Linq To Sql,嗨,伙计们,我想从两张桌子上得到一个完整的外部连接 例: 结果应该是 Table_C ------- _a _b _c 但我似乎没有得到实际的结果 这就是我所做的 IEnumerable<string> leftOuter1 = (from watcher in _watchers join attendee in attendees on watcher equals attendee into set

嗨,伙计们,我想从两张桌子上得到一个完整的外部连接

例:

结果应该是

Table_C
-------
_a
_b
_c
但我似乎没有得到实际的结果

这就是我所做的

IEnumerable<string> leftOuter1 = (from watcher in _watchers
                                     join attendee in attendees on watcher equals attendee into set
                                     from attendee in set.DefaultIfEmpty()
                                     select attendee);

    IEnumerable<string> rightOuter1 = (from attendee in attendees
                                       join watcher in _watchers on attendee equals watcher into set
                                      from watcher in set.DefaultIfEmpty()
                                      select watcher);


    IEnumerable<string> participants1 = leftOuter.Union(rightOuter);
IEnumerable leftOuter1=(来自_watchers中的watcher)
在watcher上的与会者中加入与会者等于将与会者加入集合
来自set.DefaultIfEmpty()中的与会者
选择与会者);
IEnumerable rightOuter1=(来自与会者中的与会者)
加入观察者-参与者上的观察者等于观察者进入集合
来自set.DefaultIfEmpty()中的观察者
选择观察者);
IEnumerable participants1=leftOuter.Union(righouter);
在《观察者》中,我有“a”的价值

在与会者的价值观中,“a”和“b”

第一个结果是_a,但第二个结果是_a,null。我做错了什么

谢谢你

你可以看到这个

var firstNames = new[]    {
new { ID = 1, Name = "John" },
new { ID = 2, Name = "Sue" },    };

var lastNames = new[]
{
new { ID = 1, Name = "Doe" },
new { ID = 3, Name = "Smith" },
};
var leftOuterJoin = from first in firstNames
                join last in lastNames
                on first.ID equals last.ID
                into temp
                from last in temp.DefaultIfEmpty(new { first.ID, Name =       default(string) })
                select new
                {
                    first.ID,
                    FirstName = first.Name,
                    LastName = last.Name,
                };
var rightOuterJoin = from last in lastNames
                 join first in firstNames
                 on last.ID equals first.ID
                 into temp
                 from first in temp.DefaultIfEmpty(new { last.ID, Name =     default(string) })
                 select new
                 {
                     last.ID,
                     FirstName = first.Name,
                     LastName = last.Name,
                 }; var fullOuterJoin = leftOuterJoin.Union(rightOuterJoin);

请看

成功了,谢谢
var firstNames = new[]    {
new { ID = 1, Name = "John" },
new { ID = 2, Name = "Sue" },    };

var lastNames = new[]
{
new { ID = 1, Name = "Doe" },
new { ID = 3, Name = "Smith" },
};
var leftOuterJoin = from first in firstNames
                join last in lastNames
                on first.ID equals last.ID
                into temp
                from last in temp.DefaultIfEmpty(new { first.ID, Name =       default(string) })
                select new
                {
                    first.ID,
                    FirstName = first.Name,
                    LastName = last.Name,
                };
var rightOuterJoin = from last in lastNames
                 join first in firstNames
                 on last.ID equals first.ID
                 into temp
                 from first in temp.DefaultIfEmpty(new { last.ID, Name =     default(string) })
                 select new
                 {
                     last.ID,
                     FirstName = first.Name,
                     LastName = last.Name,
                 }; var fullOuterJoin = leftOuterJoin.Union(rightOuterJoin);