public static Expression GetConstant(object value)
{
if (value == null) {
throw new ArgumentNullException("value");
}
Expression expr;
if (TryGetConstant(value, out expr)) {
return expr;
}
var message = String.Format(
"Cannot convert value of type {0} to {1}",
value.GetType(),
typeof(ConstantExpression));
throw new NotSupportedException(message);
}