Add SqlFunc.RowSum

This commit is contained in:
sunkaixuan
2023-05-15 17:49:13 +08:00
parent d2991aeb28
commit 43ede0255f
4 changed files with 11 additions and 0 deletions

View File

@@ -24,6 +24,10 @@ namespace SqlSugar
{ {
return "count(1) over()"; return "count(1) over()";
} }
public string RowSum(MethodCallExpressionModel model)
{
return "SUM(" + model.Args[0].MemberName +") over()";
}
public virtual string IIF(MethodCallExpressionModel model) public virtual string IIF(MethodCallExpressionModel model)
{ {
var parameter = model.Args[0]; var parameter = model.Args[0];

View File

@@ -90,6 +90,7 @@ namespace SqlSugar
string Stuff(MethodCallExpressionModel model); string Stuff(MethodCallExpressionModel model);
string RowNumber(MethodCallExpressionModel model); string RowNumber(MethodCallExpressionModel model);
string RowCount(MethodCallExpressionModel model); string RowCount(MethodCallExpressionModel model);
string RowSum(MethodCallExpressionModel model);
string Exists(MethodCallExpressionModel model); string Exists(MethodCallExpressionModel model);
string GetDateString(string dateValue,string format); string GetDateString(string dateValue,string format);
string GetForXmlPath(); string GetForXmlPath();

View File

@@ -33,6 +33,10 @@ namespace SqlSugar
{ {
throw new NotSupportedException("Can only be used in expressions"); throw new NotSupportedException("Can only be used in expressions");
} }
public static TRestult RowSum<TRestult>(TRestult filedName)
{
throw new NotSupportedException("Can only be used in expressions");
}
public static string JsonField(object json,string fieldName) public static string JsonField(object json,string fieldName)
{ {

View File

@@ -790,6 +790,8 @@ namespace SqlSugar
return this.Context.DbMehtods.RowNumber(model); return this.Context.DbMehtods.RowNumber(model);
case "RowCount": case "RowCount":
return this.Context.DbMehtods.RowCount(model); return this.Context.DbMehtods.RowCount(model);
case "RowSum":
return this.Context.DbMehtods.RowSum(model);
case "Exists": case "Exists":
if (model.Args.Count > 1) if (model.Args.Count > 1)
{ {