From 4933dbd8db2952e4a1715143de5ddd46b7c5263e Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 15 May 2023 17:51:57 +0800 Subject: [PATCH] Synchronization code --- .../SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs | 4 ++++ .../SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs | 1 + .../SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs | 4 ++++ .../ResolveItems/MethodCallExpressionResolve_Helper.cs | 2 ++ 4 files changed, 11 insertions(+) diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs index 579191a07..52b1c5c32 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs @@ -24,6 +24,10 @@ namespace SqlSugar { return "count(1) over()"; } + public string RowSum(MethodCallExpressionModel model) + { + return "SUM(" + 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 c71da6c64..90eedd686 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs @@ -90,6 +90,7 @@ namespace SqlSugar string Stuff(MethodCallExpressionModel model); string RowNumber(MethodCallExpressionModel model); string RowCount(MethodCallExpressionModel model); + string RowSum(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 49a471570..03d7ef1a4 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs @@ -33,6 +33,10 @@ namespace SqlSugar { throw new NotSupportedException("Can only be used in expressions"); } + public static TRestult RowSum(TRestult filedName) + { + throw new NotSupportedException("Can only be used in expressions"); + } public static string JsonField(object json,string fieldName) { diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs index 716bc03ae..a600b2337 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs @@ -790,6 +790,8 @@ namespace SqlSugar return this.Context.DbMehtods.RowNumber(model); case "RowCount": return this.Context.DbMehtods.RowCount(model); + case "RowSum": + return this.Context.DbMehtods.RowSum(model); case "Exists": if (model.Args.Count > 1) {