I have a class like the following:
public class MyData
{
public int Key { get; set; }
public string MyString { get; set; }
public bool MyFlag { get; set; }
}
I have a list of these classes:
var data = new List<MyData>();
Which is populated as follows:
data.Add(new MyData() { Key = 1, MyFlag = true, MyString = "Hello" });
data.Add(new MyData() { Key = 1, MyFlag = false, MyString = "Goodbye" });
data.Add(new MyData() { Key = 2, MyFlag = true, MyString = "Test" });
data.Add(new MyData() { Key = 2, MyFlag = false, MyString = "Merge" });
data.Add(new MyData() { Key = 3, MyFlag = false, MyString = "Data" });
What I want is a list as follows:
Key true false
1 Hello Goodbye
2 Test Merge
3 Data
I need an anonymous type that reflects the three values above. I found a few posts and articles that seemed to suggest GroupJoin, but I'm unsure how I could use that in this case as it seems to allow joining two separate lists.