LoginSignup
1
2

More than 5 years have passed since last update.

LINQでのJOINについての備忘録

Last updated at Posted at 2017-10-30

メモ書きとして内部結合と外部結合をそれぞれ。
あってるのか怪しいので間違いあればご指摘お願いいたします。

内部結合
var innerRecords = from human in humanList
                       join pc in pcList
                           on human.PcId equals pc.Id
                   where Pc.Id == "2"
                   select new {
                                    human.Name
                                  , pc.Name
                              };
外部結合
var outerRecords = from human in humanList
                       join pc in pcList
                            on human.PcId equals pc.Id into subPcList
                   from pc in subPcList.DefaultIfEmpty()
                   where pc.Id == "2"
                   select new {
                                    human.Name
                                  , pc.Name
                              };


参考: 左外部結合の実行 | Microsoft Docs

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2