C#中使用Linq实现全外连接

每次使用都到处查阅,现在记录下来,备查。

var fulljoin = (
from s in sampleRegisters
join t
in tensionDatas on new { Beach = s.Beach, Hook = s.Hook } equals new { Beach = t.Beach, Hook = t.Hook } into havematch where !havematch.Any() select new { SampleID = 0, Beach = s.Beach, Hook = s.Hook, Beacht = "",Hookt = ""}) .Concat(
from s in sampleRegisters join t in tensionDatas on new { Beach = s.Beach, Hook = s.Hook } equals new { Beach = t.Beach, Hook = t.Hook } select new { SampleID = s.SampleID, Beach = s.Beach, Hook = s.Hook, Beacht =t.Beach, Hookt = t.Hook }
) .Concat(
from t in tensionDatas join s in sampleRegisters on new { Beach = t.Beach, Hook = t.Hook } equals new { Beach = s.Beach, Hook = s.Hook } into havematch where !havematch.Any() select new { SampleID = 0, Beach ="", Hook = "", Beacht = t.Beach, Hookt = t.Hook }
);

 几个变量的类型:

SampleID:int

Beach:string

Hook:string

posted @ 2016-12-31 11:03  jqdy  阅读(1905)  评论(0编辑  收藏  举报