diff --git a/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs b/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs index c0a9c10..317d42f 100644 --- a/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs +++ b/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs @@ -73,6 +73,10 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal typeof(MathF).GetRuntimeMethod(nameof(MathF.Acos), new[] { typeof(float) }) !, typeof(MathF).GetRuntimeMethod(nameof(MathF.Asin), new[] { typeof(float) }) !, typeof(MathF).GetRuntimeMethod(nameof(MathF.Atan2), new[] { typeof(float), typeof(float) })!, + typeof(double).GetRuntimeMethod(nameof(double.DegreesToRadians), new[] { typeof(double) })!, + typeof(double).GetRuntimeMethod(nameof(double.RadiansToDegrees), new[] { typeof(double) })!, + typeof(float).GetRuntimeMethod(nameof(float.DegreesToRadians), new[] { typeof(float) })!, + typeof(float).GetRuntimeMethod(nameof(float.RadiansToDegrees), new[] { typeof(float) })!, }; private static readonly IEnumerable _truncateMethodInfos = new[] @@ -216,6 +220,9 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal new[] { true }, method.ReturnType), + nameof(double.DegreesToRadians) => _sqlExpressionFactory.Multiply(arguments[0], _sqlExpressionFactory.Divide(_sqlExpressionFactory.Constant(Math.PI), _sqlExpressionFactory.Constant(180))), + + nameof(double.RadiansToDegrees) => _sqlExpressionFactory.Multiply(arguments[0], _sqlExpressionFactory.Divide(_sqlExpressionFactory.Constant(180), _sqlExpressionFactory.Constant(Math.PI))), _ => null, }; diff --git a/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs b/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs index ce78b04..c9ec756 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs @@ -1183,9 +1183,9 @@ WHERE `o`.`OrderID` = 11077 AND SGN(`o`.`Discount`) > 0"); AssertSql( """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND DEGREES(CAST([o].[Discount] AS float)) > 0.0E0 +SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` +FROM `Order Details` AS `o` +WHERE `o`.`OrderID` = 11077 AND (CDBL(`o`.`Discount`) * (180.0 / 3.1415926535897931)) > 0.0 """); } @@ -1195,9 +1195,9 @@ WHERE [o].[OrderID] = 11077 AND DEGREES(CAST([o].[Discount] AS float)) > 0.0E0 AssertSql( """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND RADIANS(CAST([o].[Discount] AS float)) > 0.0E0 +SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` +FROM `Order Details` AS `o` +WHERE `o`.`OrderID` = 11077 AND (CDBL(`o`.`Discount`) * (3.1415926535897931 / 180.0)) > 0.0 """); } @@ -1483,9 +1483,9 @@ WHERE `o`.`OrderID` = 11077 AND SGN(`o`.`Discount`) > 0 AssertSql( """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND DEGREES([o].[Discount]) > CAST(0 AS real) +SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` +FROM `Order Details` AS `o` +WHERE `o`.`OrderID` = 11077 AND (`o`.`Discount` * (180 / 3.1415927)) > 0 """); } @@ -1495,9 +1495,9 @@ WHERE [o].[OrderID] = 11077 AND DEGREES([o].[Discount]) > CAST(0 AS real) AssertSql( """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND RADIANS([o].[Discount]) > CAST(0 AS real) +SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` +FROM `Order Details` AS `o` +WHERE `o`.`OrderID` = 11077 AND (`o`.`Discount` * (3.1415927 / 180)) > 0 """); }