mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
-
This commit is contained in:
@@ -29,10 +29,24 @@ namespace OrmTest.ExpressionTest
|
||||
ToUpper();
|
||||
ToLower();
|
||||
Trim();
|
||||
Contains();
|
||||
#endregion
|
||||
}
|
||||
base.End("Method Test");
|
||||
}
|
||||
|
||||
private void Contains()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.Contains(it.Name,"a");
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext(exp, ResolveExpressType.WhereSingle);
|
||||
expContext.Resolve();
|
||||
var value = expContext.Result.GetString();
|
||||
var pars = expContext.Parameters;
|
||||
base.Check(value, pars, "((rtrim(ltrim(@MethodConst0))) = Name )", new List<SugarParameter>() {
|
||||
new SugarParameter("@MethodConst0"," a")
|
||||
}, "Contains");
|
||||
}
|
||||
|
||||
private void Trim()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it =>NBORM.Trim(" a")==it.Name;
|
||||
|
@@ -30,5 +30,12 @@ namespace SqlSugar
|
||||
var parameter = model.Args[0];
|
||||
return string.Format(" (rtrim(ltrim({0}))) ", parameter.Value);
|
||||
}
|
||||
|
||||
public virtual object Contains(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
var parameter2 = model.Args[0];
|
||||
return string.Format(" {0} like '%'+{1}+'%' ", parameter.Value, parameter2.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,5 +15,6 @@ namespace SqlSugar
|
||||
object ToLower(MethodCallExpressionModel model);
|
||||
object ToUpper(MethodCallExpressionModel model);
|
||||
object Trim(MethodCallExpressionModel model);
|
||||
object Contains(MethodCallExpressionModel model);
|
||||
}
|
||||
}
|
||||
|
@@ -12,5 +12,6 @@ namespace SqlSugar
|
||||
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(); }
|
||||
public static bool Contains(string thisValue, string parameterValue) { throw new NotImplementedException();}
|
||||
}
|
||||
}
|
||||
|
@@ -76,6 +76,8 @@ namespace SqlSugar
|
||||
return this.Context.DbMehtods.ToUpper(model);
|
||||
case "Trim":
|
||||
return this.Context.DbMehtods.Trim(model);
|
||||
case "Contains":
|
||||
return this.Context.DbMehtods.Contains(model);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user