title: Best way to check if value is null in Expression Tree
body: <p>What is the best way to check if constant is null in Expression Trees?</p>
  
  <pre><code>// Method to call (Regex.IsMatch)
  MethodInfo isMatchMethod = typeof(Regex).GetMethod("IsMatch", new[] { typeof(string), typeof(string), typeof(RegexOptions) });
  
  // The member you want to evaluate: (x =&gt; x.&lt;property_name&gt;)
  var member = Expression.Property(param, propertyName);
  
  // The value you want to evaluate
  var constant = Expression.Convert(Expression.Constant(value), type);
  
  // How to check if constant is null???
  var expr = Expression.Call(isMatchMethod, member, constant, Expression.Constant(RegexOptions.IgnoreCase));
  
  // Doesn't work
  // Expression notNullConstant = value != null ? constant : Expression.Convert(Expression.Constant(string.Empty), type);
  //var expr = Expression.Call(isMatchMethod, member, notNullConstant, Expression.Constant(RegexOptions.IgnoreCase));
  </code></pre>