diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs index 52b1c5c32..41a33e48d 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs @@ -817,5 +817,10 @@ namespace SqlSugar { return $"{dataBaseName}.{tableName}"; } + + public virtual string Modulo(MethodCallExpressionModel model) + { + return "("+model.Args[0].MemberName + " % "+ model.Args[1].MemberName+")"; + } } } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs index 90eedd686..802add685 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs @@ -107,5 +107,6 @@ namespace SqlSugar string SplitIn(MethodCallExpressionModel model); string ListAny(MethodCallExpressionModel model); string GetTableWithDataBase(string databaseName,string tableName); + string Modulo(MethodCallExpressionModel mode); } } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs index 03d7ef1a4..72ec42e01 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs @@ -9,6 +9,10 @@ namespace SqlSugar { public partial class SqlFunc { + public static int Modulo(decimal numA, decimal numB) + { + throw new NotSupportedException("Can only be used in expressions"); + } public static int CompareTo(decimal numA, decimal numB) { throw new NotSupportedException("Can only be used in expressions"); diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs index a600b2337..8a25bab93 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs @@ -835,6 +835,8 @@ namespace SqlSugar case "ListAny": this.Context.Parameters.RemoveAll(it => model.Args[0].MemberName.ObjToString().Contains(it.ParameterName)); return this.Context.DbMehtods.ListAny(model); + case "Modulo": + return this.Context.DbMehtods.Modulo(model); default: break; } diff --git a/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleExpressionContext.cs b/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleExpressionContext.cs index 6f03bdfc9..9864dbd29 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleExpressionContext.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleExpressionContext.cs @@ -72,6 +72,10 @@ namespace SqlSugar } public partial class OracleMethod : DefaultDbMethod, IDbMethods { + public override string Modulo(MethodCallExpressionModel model) + { + return " MOD(" + model.Args[0].MemberName+ " , " + model.Args[1].MemberName+")"; + } public override string GetStringJoinSelector(string result, string separator) { return $"listagg(to_char({re