select max between two columns in linq

asp.net, c#, linq

Solution

(from pro in Products.ToList()
let max = Max(pro.DateSend, pro.DateEdit)
select max).Max()


static DateTime? Max(DateTime? a, DateTime? b)
{
    if (!a.HasValue && !b.HasValue) return a;  // doesn't matter

    if (!a.HasValue) return b;  
    if (!b.HasValue) return a;

    return a.Value > b.Value ? a : b;
}

Problem

i have dateSend Column and dateEdit Column in product table, i can select max dateSend with this code: ``` (from pro in Products.ToList() select new { pro.DateSend }).Max(); ``` but i have max between dateSend and dateEdit, please help me.

Original source