mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-18 17:48:11 +08:00
Add Sqlfunc.Abs Sqlfunc.Round
This commit is contained in:
@@ -477,5 +477,17 @@ namespace SqlSugar
|
|||||||
var array = model.Args.Skip(1).Select(it => it.IsMember?it.MemberName:it.MemberValue).ToArray();
|
var array = model.Args.Skip(1).Select(it => it.IsMember?it.MemberName:it.MemberValue).ToArray();
|
||||||
return string.Format("'"+str+ "'", array);
|
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 Oracle_ToChar(MethodCallExpressionModel model);
|
||||||
string SqlServer_DateDiff(MethodCallExpressionModel model);
|
string SqlServer_DateDiff(MethodCallExpressionModel model);
|
||||||
string Format(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 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 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 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>
|
/// <summary>
|
||||||
/// Subquery
|
/// Subquery
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -789,6 +789,10 @@ namespace SqlSugar
|
|||||||
var result = this.Context.DbMehtods.Format(model);
|
var result = this.Context.DbMehtods.Format(model);
|
||||||
this.Context.Parameters.RemoveAll(it => model.Args.Select(x=>x.MemberName.ObjToString()).Contains(it.ParameterName) );
|
this.Context.Parameters.RemoveAll(it => model.Args.Select(x=>x.MemberName.ObjToString()).Contains(it.ParameterName) );
|
||||||
return result;
|
return result;
|
||||||
|
case "Abs":
|
||||||
|
return this.Context.DbMehtods.Abs(model);
|
||||||
|
case "Round":
|
||||||
|
return this.Context.DbMehtods.Round(model);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user