I am trying to get the user's last login date and if no login records exist, return today's date. I am need some help getting there. I am getting the following error and do not even have the default value component.
Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.DateTime?'
DateTime? logdate = from userlog in
(from userlog in db.UserLogEntities
where
userlog.UserID == 1 &&
userlog.Action == "Logon" &&
userlog.ActionTag == "Success"
select new
{
userlog.LogDate,
Dummy = "x"
})
group userlog by new { userlog.Dummy } into g
select new
{
Column1 = (DateTime?)g.Max(p => p.LogDate)
};