Created
March 27, 2018 17:58
-
-
Save amantix/ce231ce0d18e4875d1b4aa1d5ac011e7 to your computer and use it in GitHub Desktop.
Left outer join
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void LinqBegin54() | |
{ | |
IEnumerable<string> a | |
= new[] {"AA", "B21", "A32", "VS", "S", "AAA"}; | |
IEnumerable<string> b | |
= new[] {"B2", "BSS3", "AD6", "SSS"}; | |
/* | |
var result = | |
a.GroupJoin(b, x => x[0], x => x[0], | |
(x, y) => y.DefaultIfEmpty("") | |
.Select(z => x + "." + z)) | |
.SelectMany(x => x) | |
.OrderBy(x => x); | |
*/ | |
var result = | |
from x in a | |
join y in b | |
on x[0] equals y[0] | |
into yy | |
from z in yy.DefaultIfEmpty("") | |
orderby x, z | |
select x + "." + z; | |
Console.WriteLine(string.Join(" ", result)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment