mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Add Sqlfunc.ToVarchar
This commit is contained in:
parent
98130e7692
commit
a52aad2da9
@ -401,5 +401,11 @@ namespace SqlSugar
|
||||
{
|
||||
return string.Format("CHARINDEX ({0},{1})", model.Args[0].MemberName, model.Args[1].MemberName);
|
||||
}
|
||||
|
||||
public string ToVarchar(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
return string.Format(" CAST({0} AS VARCHAR(MAX))", parameter.MemberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ namespace SqlSugar
|
||||
string ToInt32(MethodCallExpressionModel model);
|
||||
string ToInt64(MethodCallExpressionModel model);
|
||||
string ToString(MethodCallExpressionModel model);
|
||||
string ToVarchar(MethodCallExpressionModel model);
|
||||
string ToGuid(MethodCallExpressionModel model);
|
||||
string ToDouble(MethodCallExpressionModel model);
|
||||
string ToBool(MethodCallExpressionModel model);
|
||||
|
@ -101,6 +101,7 @@ namespace SqlSugar
|
||||
/// <returns></returns>
|
||||
public static TimeSpan ToTime(object value) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static string ToString(object value) { return value.ObjToString(); }
|
||||
public static string ToVarchar(object value) { return value.ObjToString(); }
|
||||
public static decimal ToDecimal(object value) { return value.ObjToDecimal(); }
|
||||
public static Guid ToGuid(object value) { return Guid.Parse(value.ObjToString()); }
|
||||
public static double ToDouble(object value) { return value.ObjToMoney(); }
|
||||
|
@ -611,6 +611,8 @@ namespace SqlSugar
|
||||
}
|
||||
Check.Exception(model.Args.Count > 1, "ToString (Format) is not supported, Use ToString().If time formatting can be used it.Date.Year+\"-\"+it.Data.Month+\"-\"+it.Date.Day ");
|
||||
return this.Context.DbMehtods.ToString(model);
|
||||
case "ToVarchar":
|
||||
return this.Context.DbMehtods.ToVarchar(model);
|
||||
case "ToDecimal":
|
||||
return this.Context.DbMehtods.ToDecimal(model);
|
||||
case "ToGuid":
|
||||
|
Loading…
Reference in New Issue
Block a user