mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
Add Sqlfunc.ToVarchar
This commit is contained in:
@@ -401,5 +401,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return string.Format("CHARINDEX ({0},{1})", model.Args[0].MemberName, model.Args[1].MemberName);
|
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 ToInt32(MethodCallExpressionModel model);
|
||||||
string ToInt64(MethodCallExpressionModel model);
|
string ToInt64(MethodCallExpressionModel model);
|
||||||
string ToString(MethodCallExpressionModel model);
|
string ToString(MethodCallExpressionModel model);
|
||||||
|
string ToVarchar(MethodCallExpressionModel model);
|
||||||
string ToGuid(MethodCallExpressionModel model);
|
string ToGuid(MethodCallExpressionModel model);
|
||||||
string ToDouble(MethodCallExpressionModel model);
|
string ToDouble(MethodCallExpressionModel model);
|
||||||
string ToBool(MethodCallExpressionModel model);
|
string ToBool(MethodCallExpressionModel model);
|
||||||
|
@@ -101,6 +101,7 @@ namespace SqlSugar
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static TimeSpan ToTime(object value) { throw new NotSupportedException("Can only be used in expressions"); }
|
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 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 decimal ToDecimal(object value) { return value.ObjToDecimal(); }
|
||||||
public static Guid ToGuid(object value) { return Guid.Parse(value.ObjToString()); }
|
public static Guid ToGuid(object value) { return Guid.Parse(value.ObjToString()); }
|
||||||
public static double ToDouble(object value) { return value.ObjToMoney(); }
|
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 ");
|
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);
|
return this.Context.DbMehtods.ToString(model);
|
||||||
|
case "ToVarchar":
|
||||||
|
return this.Context.DbMehtods.ToVarchar(model);
|
||||||
case "ToDecimal":
|
case "ToDecimal":
|
||||||
return this.Context.DbMehtods.ToDecimal(model);
|
return this.Context.DbMehtods.ToDecimal(model);
|
||||||
case "ToGuid":
|
case "ToGuid":
|
||||||
|
Reference in New Issue
Block a user