From 73ef68188f831d1a9fdc84eefda2dd1ac9dd09d6 Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Tue, 18 Apr 2023 23:40:53 +0800 Subject: [PATCH] Ordering of boolean: Rather order by the NOT expression rather than change the ascending or descending order. NULL values are handled in the correct order now Division: If the result of the binary is meant to be integer, use the Jet binary divide operatior '\' --- .../Query/Sql/Internal/JetQuerySqlGenerator.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/EFCore.Jet/Query/Sql/Internal/JetQuerySqlGenerator.cs b/src/EFCore.Jet/Query/Sql/Internal/JetQuerySqlGenerator.cs index 15f8b71..3b1af50 100644 --- a/src/EFCore.Jet/Query/Sql/Internal/JetQuerySqlGenerator.cs +++ b/src/EFCore.Jet/Query/Sql/Internal/JetQuerySqlGenerator.cs @@ -253,8 +253,12 @@ namespace EntityFrameworkCore.Jet.Query.Sql.Internal if (orderingExpression.Expression.TypeMapping?.GetType() == _boolTypeMapping?.GetType()) { orderingExpression = new OrderingExpression( - orderingExpression.Expression, - !orderingExpression.IsAscending); + new SqlUnaryExpression( + ExpressionType.Not, + orderingExpression.Expression, + orderingExpression.Expression.Type, + orderingExpression.Expression.TypeMapping), + orderingExpression.IsAscending); } return base.VisitOrdering(orderingExpression); @@ -388,6 +392,7 @@ namespace EntityFrameworkCore.Jet.Query.Sql.Internal ExpressionType.And => " BAND ", ExpressionType.Modulo => " MOD ", ExpressionType.Or => " BOR ", + ExpressionType.Divide when binaryExpression.Type == typeof(Int32) => " \\ ", _ => base.GetOperator(binaryExpression), };