I'm filtering a list by grouping on two parameters and selecting the most recent type in the sub-grouplist based on createdate (using first()). This eliminates the duplicates on the x.application and x.externalid properties.
var list = ((List<SomeType>)xDic)
.GroupBy(x => new {x.Application, x.ExternalID})
.OrderByDescending(z => z.First().CreateDate)
.Select(y => y.First()).ToList();
What I am having trouble with is defining yet another combination of properties (x.application and x.externaldisplayid) to filter with and group by to take the first one.
To summarize, I need to get a unique List of SomeTypes by filtering out any duplicates based on the ((x.application/x.externalid) OR (x.application/x.externaldisplayid)) combinations.
Example set:
{ "extID": 1234, "extDspID" : 111, "App" : "Test", "CreateDate": 2/01/2015}
{ "extID": 1234, "extDspID" : 5, "App" : "Test", "CreateDate": 1/01/2015}
{ "extID": 012, "extDspID" : 90, "App" : "Mono", "CreateDate": 6/06/2015}
{ "extID": 999, "extDspID" : 78, "App" : "Epic", "CreateDate": 8/08/2015}
{ "extID": 333, "extDspID" : 78, "App" : "Epic", "CreateDate": 8/12/2015}
{ "extID": 345, "extDspID" : 33, "App" : "Test", "CreateDate": 2/01/2015}
{ "extID": 666, "extDspID" : 33, "App" : "Test", "CreateDate": 1/01/2015}
desired result:
{ "extID": 1234, "extDspID" : 111, "App" : "Test", "CreateDate": 2/01/2015}
{ "extID": 012, "extDspID" : 90, "App" : "Mono", "CreateDate": 6/06/2015}
{ "extID": 333, "extDspID" : 78, "App" : "Epic", "CreateDate": 8/12/2015}
{ "extID": 345, "extDspID" : 33, "App" : "Test", "CreateDate": 2/01/2015}