Suppose I have two lists of type MyCustomType, a class which could be like this:
public class MyCustomType{
public int Classification {get; set;}
public string Title {get; set;}
public string Text {get; set;}
}
I want to create a third list of type Tuple<MyCustomType,MyCustomType>, which will contain some sort of a “full outer join” between them, based on a condition (e.g. put them together if they got the same Title and Classification)
Example:
list1:
Classification Title Text
Movie 300 bla
Game Star Wars the dark side are they
list2:
Movie 300 updated bla
TV Show CSI cool
The result then would be
list3:
MyCustomType MyCustomType
Movie 300 bla Movie 300 updated bla
Game Star Wars the dark side are they (null)
(null) TV Show CSI cool
They would match items by Classification and Title, and put a null on the other side when one does not match.
How could I do that (possibly using LINQ?)
I’m developing in C#, .NET 4.0.
I want this for my experimental project for C#, a ‘semantic’ C# merge tool using Roslyn. I want to compare and match SyntaxNodes by type and name.
Outer joins are not natively supported in Linq. But you can do a left join and a right join, and then put the two together:
EDIT: if you want an outer non-equijoin, you can do something like that:
(untested)