title: Linq Max with Default Value
body: <p>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.</p>
  
  <blockquote>
    <p>Cannot implicitly convert type
    'System.Linq.IQueryable' to 'System.DateTime?'</p>
  </blockquote>
  
  <pre><code>DateTime? logdate = from userlog in
                                      (from userlog in db.UserLogEntities
                                       where
                                         userlog.UserID == 1 &amp;&amp;
                                         userlog.Action == "Logon" &amp;&amp;
                                         userlog.ActionTag == "Success"
                                       select new
                                       {
                                           userlog.LogDate,
                                           Dummy = "x"
                                       })
                                  group userlog by new { userlog.Dummy } into g
                                  select new
                                  {
                                      Column1 = (DateTime?)g.Max(p =&gt; p.LogDate)
                                  };
  </code></pre>