I have this 2 lists list1 and list2 and created this GroupJoin:
List1 is a list of Persons (Id, Name) and list2 is a list of Objects (Id, Car, Date).
PS: list1 contains arround 40 elements and list2 for the moment only one element.
I try to set the maxDate but get the error "Sequence contains no elements"
var result = list1.GroupJoin(list2,
l1 => l1.Id,
l2 => l2.Id
(a, b) => new
{
listA = a,
maxDate = b?.Max(m => m.Date).Date ??
new DateTime(2000, 01, 01)
}).ToList();