mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Add Sqlfunc.Abs Sqlfunc.Round
This commit is contained in:
parent
d2c3907b5f
commit
b0db25a094
@ -477,5 +477,17 @@ namespace SqlSugar
|
||||
var array = model.Args.Skip(1).Select(it => it.IsMember?it.MemberName:it.MemberValue).ToArray();
|
||||
return string.Format("'"+str+ "'", array);
|
||||
}
|
||||
|
||||
public string Abs(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
return string.Format(" ABS({0}) ", parameter.MemberName);
|
||||
}
|
||||
|
||||
public string Round(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
return string.Format(" ROUND({0},{1}) ", parameter.MemberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,5 +73,7 @@ namespace SqlSugar
|
||||
string Oracle_ToChar(MethodCallExpressionModel model);
|
||||
string SqlServer_DateDiff(MethodCallExpressionModel model);
|
||||
string Format(MethodCallExpressionModel model);
|
||||
string Abs(MethodCallExpressionModel model);
|
||||
string Round(MethodCallExpressionModel model);
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +130,11 @@ namespace SqlSugar
|
||||
public static TResult GetSelfAndAutoFill<TResult>(TResult value) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static DateTime GetDate() { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static string GetRandom() { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
|
||||
|
||||
public static T Abs<T>( T value) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static string Round<T>(T value,int precision) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
|
||||
/// <summary>
|
||||
/// Subquery
|
||||
/// </summary>
|
||||
|
@ -789,6 +789,10 @@ namespace SqlSugar
|
||||
var result = this.Context.DbMehtods.Format(model);
|
||||
this.Context.Parameters.RemoveAll(it => model.Args.Select(x=>x.MemberName.ObjToString()).Contains(it.ParameterName) );
|
||||
return result;
|
||||
case "Abs":
|
||||
return this.Context.DbMehtods.Abs(model);
|
||||
case "Round":
|
||||
return this.Context.DbMehtods.Round(model);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user