diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs index 11b2ad912de..bd10f08bc95 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs @@ -52,13 +52,46 @@ public class SqlServerMathTranslator : IMethodCallTranslator { typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Sign), new[] { typeof(int) }), "SIGN" }, { typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Sign), new[] { typeof(long) }), "SIGN" }, { typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Sign), new[] { typeof(sbyte) }), "SIGN" }, - { typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Sign), new[] { typeof(short) }), "SIGN" } + { typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Sign), new[] { typeof(short) }), "SIGN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Abs), new[] { typeof(decimal) }), "ABS" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Abs), new[] { typeof(double) }), "ABS" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Abs), new[] { typeof(float) }), "ABS" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Abs), new[] { typeof(int) }), "ABS" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Abs), new[] { typeof(long) }), "ABS" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Abs), new[] { typeof(sbyte) }), "ABS" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Abs), new[] { typeof(short) }), "ABS" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Ceiling), new[] { typeof(decimal) }), "CEILING" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Ceiling), new[] { typeof(double) }), "CEILING" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Floor), new[] { typeof(decimal) }), "FLOOR" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Floor), new[] { typeof(double) }), "FLOOR" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Pow), new[] { typeof(double), typeof(double) }), "POWER" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Exp), new[] { typeof(double) }), "EXP" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Log10), new[] { typeof(double) }), "LOG10" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Log), new[] { typeof(double) }), "LOG" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Log), new[] { typeof(double), typeof(double) }), "LOG" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Sqrt), new[] { typeof(double) }), "SQRT" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Acos), new[] { typeof(double) }), "ACOS" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Asin), new[] { typeof(double) }), "ASIN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Atan), new[] { typeof(double) }), "ATAN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Atan2), new[] { typeof(double), typeof(double) }), "ATN2" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Cos), new[] { typeof(double) }), "COS" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Sin), new[] { typeof(double) }), "SIN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Tan), new[] { typeof(double) }), "TAN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Sign), new[] { typeof(decimal) }), "SIGN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Sign), new[] { typeof(double) }), "SIGN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Sign), new[] { typeof(float) }), "SIGN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Sign), new[] { typeof(int) }), "SIGN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Sign), new[] { typeof(long) }), "SIGN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Sign), new[] { typeof(sbyte) }), "SIGN" }, + { typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Sign), new[] { typeof(short) }), "SIGN" } }; private static readonly IEnumerable _truncateMethodInfos = new[] { typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Truncate), new[] { typeof(decimal) }), - typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Truncate), new[] { typeof(double) }) + typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Truncate), new[] { typeof(double) }), + typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Truncate), new[] { typeof(decimal) }), + typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Truncate), new[] { typeof(double) }) }; private static readonly IEnumerable _roundMethodInfos = new[] @@ -66,7 +99,11 @@ public class SqlServerMathTranslator : IMethodCallTranslator typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Round), new[] { typeof(decimal) }), typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Round), new[] { typeof(double) }), typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Round), new[] { typeof(decimal), typeof(int) }), - typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Round), new[] { typeof(double), typeof(int) }) + typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Round), new[] { typeof(double), typeof(int) }), + typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Round), new[] { typeof(decimal) }), + typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Round), new[] { typeof(double) }), + typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Round), new[] { typeof(decimal), typeof(int) }), + typeof(MathF).GetRequiredRuntimeMethod(nameof(MathF.Round), new[] { typeof(double), typeof(int) }) }; private readonly ISqlExpressionFactory _sqlExpressionFactory; diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs index effb424b087..0b00ab78f7a 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs @@ -48,7 +48,33 @@ public class SqliteMathTranslator : IMethodCallTranslator { typeof(Math).GetRequiredMethod(nameof(Math.Min), new[] { typeof(uint), typeof(uint) }), "min" }, { typeof(Math).GetRequiredMethod(nameof(Math.Min), new[] { typeof(ushort), typeof(ushort) }), "min" }, { typeof(Math).GetRequiredMethod(nameof(Math.Round), new[] { typeof(double) }), "round" }, - { typeof(Math).GetRequiredMethod(nameof(Math.Round), new[] { typeof(double), typeof(int) }), "round" } + { typeof(Math).GetRequiredMethod(nameof(Math.Round), new[] { typeof(double), typeof(int) }), "round" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Abs), new[] { typeof(double) }), "abs" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Abs), new[] { typeof(float) }), "abs" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Abs), new[] { typeof(int) }), "abs" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Abs), new[] { typeof(long) }), "abs" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Abs), new[] { typeof(sbyte) }), "abs" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Abs), new[] { typeof(short) }), "abs" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Max), new[] { typeof(byte), typeof(byte) }), "max" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Max), new[] { typeof(double), typeof(double) }), "max" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Max), new[] { typeof(float), typeof(float) }), "max" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Max), new[] { typeof(int), typeof(int) }), "max" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Max), new[] { typeof(long), typeof(long) }), "max" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Max), new[] { typeof(sbyte), typeof(sbyte) }), "max" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Max), new[] { typeof(short), typeof(short) }), "max" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Max), new[] { typeof(uint), typeof(uint) }), "max" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Max), new[] { typeof(ushort), typeof(ushort) }), "max" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Min), new[] { typeof(byte), typeof(byte) }), "min" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Min), new[] { typeof(double), typeof(double) }), "min" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Min), new[] { typeof(float), typeof(float) }), "min" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Min), new[] { typeof(int), typeof(int) }), "min" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Min), new[] { typeof(long), typeof(long) }), "min" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Min), new[] { typeof(sbyte), typeof(sbyte) }), "min" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Min), new[] { typeof(short), typeof(short) }), "min" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Min), new[] { typeof(uint), typeof(uint) }), "min" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Min), new[] { typeof(ushort), typeof(ushort) }), "min" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Round), new[] { typeof(double) }), "round" }, + { typeof(MathF).GetRequiredMethod(nameof(MathF.Round), new[] { typeof(double), typeof(int) }), "round" } }; private readonly ISqlExpressionFactory _sqlExpressionFactory;