My data looks like the following image
So i loaded it into a collection, using anon objects to bypass creating a class
List<dynamic> myList = new List<dynamic>()
{
new {
WorkOrderID = 40001,
LastUpdatedAt = DateTime.Parse("2018-10-02"),
Col3 = "abc",
Col4 = "xyz"
},
new {
WorkOrderID = 40001,
LastUpdatedAt = DateTime.Parse("2017-06-01"),
Col3 = "abc",
Col4 = "xyz"
},
new {
WorkOrderID = 40002,
LastUpdatedAt = DateTime.Parse("2018-07-01"),
Col3 = "abc",
Col4 = "xyz"
},
new {
WorkOrderID = 40003,
LastUpdatedAt = DateTime.Parse("2018-09-01"),
Col3 = "abc",
Col4 = "xyz"
},
new {
WorkOrderID = 40001,
LastUpdatedAt = DateTime.Parse("2016-01-01"),
Col3 = "abc",
Col4 = "xyz"
},
new {
WorkOrderID = 40002,
LastUpdatedAt = DateTime.Parse("2016-12-01"),
Col3 = "abc",
Col4 = "xyz"
},
};
How do I use Linq-to-Objects to extract only DISTINCT WorkOrders that were updated most recently.
In other words, i should end up with the 3 rows highlighted in Orange.
var myFilteredList = myList.GroupBy( //?? Totally lost... help...