1
Vote

Expression Constant comparing Nullable<DateTime> fails with InvalidOperationException

description

The exception below occurs when comparing an object property that is a Nullable<DateTime>. The attached file resolved the problem.
 
System.InvalidOperationException was unhandled
Message=The binary operator LessThanOrEqual is not defined for the types 'System.Nullable`1[System.DateTime]' and 'System.DateTime'.
Source=System.Core
StackTrace:
   at System.Linq.Expressions.Expression.GetComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull)
   at System.Linq.Expressions.Expression.LessThanOrEqual(Expression left, Expression right, Boolean liftToNull, MethodInfo method)
   at System.Linq.Expressions.Expression.MakeBinary(ExpressionType binaryType, Expression left, Expression right, Boolean liftToNull, MethodInfo method, LambdaExpression conversion)
   at System.Linq.Expressions.Expression.MakeBinary(ExpressionType binaryType, Expression left, Expression right)
   at ExpressionBuilder.EditableBinaryExpression.ToExpression() in D:\Visual Studio Projects\Deloitte - Innovation Center\Dev\Phase 1\TestApps\Diet.Expressions\ExpressionBuilder\Expressions\EditableBinaryExpression.cs:line 48
   at ExpressionBuilder.EditableBinaryExpression.ToExpression() in D:\Visual Studio Projects\Deloitte - Innovation Center\Dev\Phase 1\TestApps\Diet.Expressions\ExpressionBuilder\Expressions\EditableBinaryExpression.cs:line 48
   at ExpressionBuilder.EditableBinaryExpression.ToExpression() in D:\Visual Studio Projects\Deloitte - Innovation Center\Dev\Phase 1\TestApps\Diet.Expressions\ExpressionBuilder\Expressions\EditableBinaryExpression.cs:line 48
   at ExpressionBuilder.EditableLambdaExpression.ToExpression() in D:\Visual Studio Projects\Deloitte - Innovation Center\Dev\Phase 1\TestApps\Diet.Expressions\ExpressionBuilder\Expressions\EditableLambdaExpression.cs:line 53

file attachments

comments