title: Conversion of Expression with nullable DateTime gives an error
body: <p>In a class, I have a static method to fetch the PropertyInfo by supplying an expression.</p>
  
  <pre><code>public static PropertyInfo GetPropertyInfo&lt;T&gt;(Expression&lt;Func&lt;T, object&gt;&gt; expressie)
          {
              MemberExpression me;
              switch (expressie.Body.NodeType)
              {
                  case ExpressionType.Convert:
                  case ExpressionType.ConvertChecked:
                      var ue = expressie.Body as UnaryExpression;
                      me = ((ue != null) ? ue.Operand : null) as MemberExpression;
                      break;
                  default:
                      me = expressie.Body as MemberExpression;
                      break;
              }
              if (me == null)
              {
                  throw new InvalidOperationException("Expression does not refer to a property: " + expressie.ToString());
              }
  
              return (PropertyInfo)me.Member;
          }
  </code></pre>
  
  <p>To make my code more type safe, I changed the expressions that I'm using in part of the methods which make a call to this function.</p>
  
  <pre><code>// Old
  Expression&lt;Func&lt;T, Object&gt;&gt; expression;
  
  // New (TProp instead of Object)
  Expression&lt;Func&lt;T, TProp&gt;&gt; expression;
  </code></pre>
  
  <p>As a result, I can't use the old 'GetPropertyInfo' method anymore, because the expression does not match the requested parameters. So I created a new one.</p>
  
  <pre><code>public static PropertyInfo GetPropertyInfo&lt;T, TProp&gt;(Expression&lt;Func&lt;T, TProp&gt;&gt; expressie)
          {
              MemberExpression me;
              switch (expressie.Body.NodeType)
              {
                  case ExpressionType.Convert:
                  case ExpressionType.ConvertChecked:
                      var ue = expressie.Body as UnaryExpression;
                      me = ((ue != null) ? ue.Operand : null) as MemberExpression;
                      break;
                  default:
                      me = expressie.Body as MemberExpression;
                      break;
              }
              if (me == null)
              {
                  throw new InvalidOperationException("Expression does not refer to a property: " + expressie.ToString());
              }
  
              return (PropertyInfo)me.Member;
          }
  </code></pre>
  
  <p>The body of this new expression is exactly the same as the existing one. Because I would like to stick with the DRY principle, I searched for a way to use one method body for both cases. This is possible by first converting the 'Expression&lt;Func&lt;T, TProp&gt;&gt;' into 'Expression&lt;Func&lt;T, Object&gt;&gt;' and passing the converted expression to the 'old' GetPropertyInfo(...) method. I am not able to completely remove the old 'GetPropertyInfo' method, because of other pieces of code still relying on it.</p>
  
  <p>The conversion method that I'm using is the following:</p>
  
  <pre><code>private static Expression&lt;Func&lt;T, object&gt;&gt; convertToObjectExpression&lt;T, TProp&gt;(Expression&lt;Func&lt;T, TProp&gt;&gt; expression)
          {
              return Expression.Lambda&lt;Func&lt;T,object&gt;&gt;(
                      Expression.Convert(expression.Body, typeof(object)),
                      expression.Parameters);
          }
  </code></pre>
  
  <p>This works fine, except when I'm using the expression with a nullable DateTime (DateTime?) as type of TProp. In that case the following line results in 'me' being null.</p>
  
  <pre><code>me = ((ue != null) ? ue.Operand : null) as MemberExpression;
  </code></pre>
  
  <p>Does anybody have any idea what can cause this problem?</p>
  
  <p>I have a <a href="https://dotnetfiddle.net/DG735N" rel="nofollow">fiddle</a> that contains the problem.</p>