Breeze / breeze.server.net

Breeze support for .NET servers
MIT License
76 stars 62 forks source link

The binary operator GreaterThan is not defined for the types 'System.String' and 'System.String' #125

Closed iulianb closed 2 years ago

iulianb commented 3 years ago

In some cases, DevExtreme generates filters that use '<' or '>' on string properties, which triggers the exception in the title when the query hits the server. I can see that the BinaryPredicate class doesn't account for this case. Is it intentional?

steveschmitt commented 3 years ago

If EntityFramework can make sense of it, then BinaryPredicate should allow it, I think.

iulianb commented 3 years ago

Here's the stack trace for the exception.

   at System.Linq.Expressions.Expression.GetUserDefinedBinaryOperatorOrThrow(ExpressionType binaryType, String name, Expression left, Expression right, Boolean liftToNull)
   at System.Linq.Expressions.Expression.GetComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull)
   at System.Linq.Expressions.Expression.GreaterThan(Expression left, Expression right, Boolean liftToNull, MethodInfo method)
   at System.Linq.Expressions.Expression.GreaterThan(Expression left, Expression right)
   at Breeze.Core.BinaryPredicate.BuildBinaryExpr(Expression expr1, Expression expr2, Operator op)
   at Breeze.Core.BinaryPredicate.ToExpression(ParameterExpression paramExpr)
   at Breeze.Core.AndOrPredicate.<>c__DisplayClass6_0.<ToExpression>b__0(BasePredicate p)
   at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.Aggregate[TSource](IEnumerable`1 source, Func`3 func)
   at Breeze.Core.AndOrPredicate.BuildAndOrExpr(IEnumerable`1 exprs, Operator op)
   at Breeze.Core.AndOrPredicate.ToExpression(ParameterExpression paramExpr)
   at Breeze.Core.BasePredicate.ToLambda(Type entityType)
   at Breeze.Core.QueryBuilder.ApplyWhere(IQueryable source, Type elementType, BasePredicate predicate)
   at Breeze.Core.EntityQueryExtensions.ApplyWhere(EntityQuery eq, IQueryable queryable, Type eleType)
   at Breeze.AspNetCore.BreezeQueryFilterAttribute.OnActionExecuted(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.<OnActionExecutionAsync>d__6.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeNextActionFilterAsync>g__Awaited|10_0>d.MoveNext()

.NET Core 3.1 Breeze.AspNetCore.NetCore 3.0.1

jtraband commented 2 years ago

Cannot repro