title: Dynamic Linq .Select() - How to handle certain null values
body: <p>I am using System.Linq.Dynamic for a project that requires the user to choose which properties will be selected/projected at runtime.</p>
  
  <p>So, I have a query like this:</p>
  
  <pre><code>var query = db.Users.Select("New(UserId, Username, Groups.Max(DateInserted) AS DateInserted)");
  </code></pre>
  
  <p>The DateInserted column is not null, but not all users have groups.
  So, when a user is returned without groups, I get the following error:</p>
  
  <pre><code>"The cast to value type 'DateTime' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type."
  </code></pre>
  
  <p>Is there anything I can do in the query?  I cannot make the column nullable.</p>
  
  <p>Thanks for any help.</p>