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 = , 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 = , Beach ="", Hook = "", Beacht = t.Beach, Hookt = t.Hook }
);

几个变量的类型:

SampleID:int

Beach:string

Hook:string

上一篇:python笔记9-字符串操作


下一篇:第八章 Hyper-V 2012 R2 故障转移群集