mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 02:14:53 +08:00
-
This commit is contained in:
@@ -28,10 +28,22 @@ namespace OrmTest.ExpressionTest
|
||||
StringIsNullOrEmpty4();
|
||||
ToUpper();
|
||||
ToLower();
|
||||
Trim();
|
||||
#endregion
|
||||
}
|
||||
base.End("Method Test");
|
||||
}
|
||||
private void Trim()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it =>NBORM.Trim(" a")==it.Name;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext(exp, ResolveExpressType.WhereSingle);
|
||||
expContext.Resolve();
|
||||
var value = expContext.Result.GetString();
|
||||
var pars = expContext.Parameters;
|
||||
base.Check(value, pars, "( @Const0 = (UPPER(Id)) )", new List<SugarParameter>() {
|
||||
new SugarParameter("@Const0","a")
|
||||
}, "ToUpper");
|
||||
}
|
||||
|
||||
private void ToUpper()
|
||||
{
|
||||
|
||||
@@ -24,5 +24,11 @@ namespace SqlSugar
|
||||
var parameter = model.Args[0];
|
||||
return string.Format(" (LOWER({0})) ", parameter.Value);
|
||||
}
|
||||
|
||||
public object Trim(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
return string.Format(" (rtrim(ltrim({0}))) ", parameter.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,6 @@ namespace SqlSugar
|
||||
string IsNullOrEmpty(MethodCallExpressionModel model);
|
||||
object ToLower(MethodCallExpressionModel model);
|
||||
object ToUpper(MethodCallExpressionModel model);
|
||||
object Trim(MethodCallExpressionModel model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,6 @@ namespace SqlSugar
|
||||
public static bool IsNullOrEmpty(object thisValue) { throw new NotImplementedException(); }
|
||||
public static string ToLower(object thisValue) { throw new NotImplementedException(); }
|
||||
public static string ToUpper(object thisValue) { throw new NotImplementedException(); }
|
||||
public static string Trim(object thisValue) { throw new NotImplementedException(); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ namespace SqlSugar
|
||||
return this.Context.DbMehtods.ToLower(model);
|
||||
case "ToUpper":
|
||||
return this.Context.DbMehtods.ToUpper(model);
|
||||
case "Trim":
|
||||
return this.Context.DbMehtods.Trim(model);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user