Say I’ve got 2 lists that look something like
ID | IsChipCollected | IsShirtCollected | IsPackCollected
A 0 1 0 1
1 0 1 0
2 0 0 1
B 0 0 1 0
1 0 0 1
2 1 1 1
Basically I need to compare and merge the 2 lists and if a certain flag has been set to say true in B, i should select it instead of A
I know how to achieve this with a single column, but I’m struggling wrapping my head around doing it in a scenario with 2+ columns
var result = A.Concat(B)
.GroupBy(x => x.Id)
.Select(g => g.OrderByDescending(x => x.IsShirtCollected).First())
I’ll update my code sample if i make any progress on this, (as I’m currently still hacking away :P)
Expected Result
ID | IsChipCollected | IsShirtCollected | IsPackCollected
0 1 1 1
1 0 1 1
2 1 1 1
Edit
Following Servy’s (good) idea (changing 1 / 0 to boolean values)