Implement Degrees to Radians and Radians to Degrees by first principal as there is no inbulilt function. Thankfully it is not a difficult calculation

pull/144/head
Christopher Jolly 2 years ago
parent 009b9de606
commit 01775d1b2f

@ -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<MethodInfo> _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,
};

@ -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
""");
}

Loading…
Cancel
Save