Browse Source

Update Expression Resolve

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
f566a6ea19
  1. 38
      SqlServerTest/Program.cs
  2. 12
      SqlServerTest/UnitTest/ExpressionTest/Method.cs
  3. 1
      SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

38
SqlServerTest/Program.cs

@ -18,31 +18,31 @@ namespace OrmTest
static void Main(string[] args) static void Main(string[] args)
{ {
/***Unit Test***/ /***Unit Test***/
//new Field(1).Init(); new Field(1).Init();
//new Where(1).Init(); new Where(1).Init();
new Method(1).Init(); new Method(1).Init();
//new JoinQuery(1).Init(); new JoinQuery(1).Init();
//new SingleQuery(1).Init(); new SingleQuery(1).Init();
//new SelectQuery(1).Init(); new SelectQuery(1).Init();
//new AutoClose(1).Init(); new AutoClose(1).Init();
new Insert(1).Init(); new Insert(1).Init();
//new Delete(1).Init(); new Delete(1).Init();
//new Update(1).Init(); new Update(1).Init();
//new Mapping(1).Init(); new Mapping(1).Init();
//new DataTest(1).Init(); new DataTest(1).Init();
/***Performance Test***/ /***Performance Test***/
new SqlSugarPerformance(100).Select(); new SqlSugarPerformance(100).Select();
/***Demo***/ /***Demo***/
//OrmTest.Demo.Query.Init(); OrmTest.Demo.Query.Init();
//OrmTest.Demo.Insert.Init(); OrmTest.Demo.Insert.Init();
//OrmTest.Demo.Delete.Init(); OrmTest.Demo.Delete.Init();
//OrmTest.Demo.Update.Init(); OrmTest.Demo.Update.Init();
//OrmTest.Demo.DbFirst.Init(); OrmTest.Demo.DbFirst.Init();
//OrmTest.Demo.JoinSql.Init(); OrmTest.Demo.JoinSql.Init();
//OrmTest.Demo.Filter.Init(); OrmTest.Demo.Filter.Init();
//OrmTest.Demo.MaterSlave.Init(); OrmTest.Demo.MaterSlave.Init();
//OrmTest.Demo.ComplexModel.Init(); OrmTest.Demo.ComplexModel.Init();
} }
} }
} }

12
SqlServerTest/UnitTest/ExpressionTest/Method.cs

@ -45,6 +45,7 @@ namespace OrmTest.UnitTest
ToLower(); ToLower();
Trim(); Trim();
Contains(); Contains();
Contains2();
ContainsArray(); ContainsArray();
StartsWith(); StartsWith();
EndsWith(); EndsWith();
@ -416,6 +417,17 @@ namespace OrmTest.UnitTest
new SugarParameter("@MethodConst0","a") new SugarParameter("@MethodConst0","a")
}, "Contains error"); }, "Contains error");
} }
private void Contains2(string name="a")
{
Expression<Func<Student, bool>> exp = it => SqlFunc.Contains(it.Name, name);
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, " ([Name] like '%'+@MethodConst0+'%') ", new List<SugarParameter>() {
new SugarParameter("@MethodConst0","a")
}, "Contains2 error");
}
private void ExtendContainsArray() { private void ExtendContainsArray() {
string[] array = new string[] { "1", "2" }; string[] array = new string[] { "1", "2" };

1
SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -148,6 +148,7 @@ namespace SqlSugar
this.Context.Parameters.Add(new SugarParameter(parameterName, value)); this.Context.Parameters.Add(new SugarParameter(parameterName, value));
} }
model.Args.Add(methodCallExpressionArgs); model.Args.Add(methodCallExpressionArgs);
parameter.ChildExpression = null;
} }
private object GetMdthodValue(string name, MethodCallExpressionModel model) private object GetMdthodValue(string name, MethodCallExpressionModel model)

Loading…
Cancel
Save