diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs index 41a33e48d..91de6efd0 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs @@ -28,6 +28,18 @@ namespace SqlSugar { return "SUM(" + model.Args[0].MemberName +") over()"; } + public string RowAvg(MethodCallExpressionModel model) + { + return "AVG(" + model.Args[0].MemberName + ") over()"; + } + public string RowMin(MethodCallExpressionModel model) + { + return "Min(" + model.Args[0].MemberName + ") over()"; + } + public string RowMax(MethodCallExpressionModel model) + { + return "Max(" + model.Args[0].MemberName + ") over()"; + } public virtual string IIF(MethodCallExpressionModel model) { var parameter = model.Args[0]; diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs index 802add685..35adff053 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs @@ -91,6 +91,9 @@ namespace SqlSugar string RowNumber(MethodCallExpressionModel model); string RowCount(MethodCallExpressionModel model); string RowSum(MethodCallExpressionModel model); + string RowMin(MethodCallExpressionModel model); + string RowMax(MethodCallExpressionModel model); + string RowAvg(MethodCallExpressionModel model); string Exists(MethodCallExpressionModel model); string GetDateString(string dateValue,string format); string GetForXmlPath(); diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs index 72ec42e01..1ce466d86 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs @@ -41,7 +41,18 @@ namespace SqlSugar { throw new NotSupportedException("Can only be used in expressions"); } - + public static TRestult RowMax(TRestult filedName) + { + throw new NotSupportedException("Can only be used in expressions"); + } + public static TRestult RowMin(TRestult filedName) + { + throw new NotSupportedException("Can only be used in expressions"); + } + public static TRestult RowAvg(TRestult filedName) + { + throw new NotSupportedException("Can only be used in expressions"); + } public static string JsonField(object json,string fieldName) { throw new NotSupportedException("Can only be used in expressions"); diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs index d6a40cc02..9d1ab3dfe 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs @@ -792,6 +792,12 @@ namespace SqlSugar return this.Context.DbMehtods.RowCount(model); case "RowSum": return this.Context.DbMehtods.RowSum(model); + case "RowMax": + return this.Context.DbMehtods.RowMax(model); + case "RowMin": + return this.Context.DbMehtods.RowMin(model); + case "RowAvg": + return this.Context.DbMehtods.RowAvg(model); case "Exists": if (model.Args.Count > 1) {