From f566a6ea19c2ffc8d543b208a798b3df609f1c6b Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Thu, 15 Jun 2017 07:43:58 +0800 Subject: [PATCH] Update Expression Resolve --- SqlServerTest/Program.cs | 38 +++++++++---------- .../UnitTest/ExpressionTest/Method.cs | 12 ++++++ .../MethodCallExpressionResolve.cs | 1 + 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/SqlServerTest/Program.cs b/SqlServerTest/Program.cs index 134f67b9c..caafd709e 100644 --- a/SqlServerTest/Program.cs +++ b/SqlServerTest/Program.cs @@ -18,31 +18,31 @@ namespace OrmTest static void Main(string[] args) { /***Unit Test***/ - //new Field(1).Init(); - //new Where(1).Init(); + new Field(1).Init(); + new Where(1).Init(); new Method(1).Init(); - //new JoinQuery(1).Init(); - //new SingleQuery(1).Init(); - //new SelectQuery(1).Init(); - //new AutoClose(1).Init(); + new JoinQuery(1).Init(); + new SingleQuery(1).Init(); + new SelectQuery(1).Init(); + new AutoClose(1).Init(); new Insert(1).Init(); - //new Delete(1).Init(); - //new Update(1).Init(); - //new Mapping(1).Init(); - //new DataTest(1).Init(); + new Delete(1).Init(); + new Update(1).Init(); + new Mapping(1).Init(); + new DataTest(1).Init(); /***Performance Test***/ new SqlSugarPerformance(100).Select(); /***Demo***/ - //OrmTest.Demo.Query.Init(); - //OrmTest.Demo.Insert.Init(); - //OrmTest.Demo.Delete.Init(); - //OrmTest.Demo.Update.Init(); - //OrmTest.Demo.DbFirst.Init(); - //OrmTest.Demo.JoinSql.Init(); - //OrmTest.Demo.Filter.Init(); - //OrmTest.Demo.MaterSlave.Init(); - //OrmTest.Demo.ComplexModel.Init(); + OrmTest.Demo.Query.Init(); + OrmTest.Demo.Insert.Init(); + OrmTest.Demo.Delete.Init(); + OrmTest.Demo.Update.Init(); + OrmTest.Demo.DbFirst.Init(); + OrmTest.Demo.JoinSql.Init(); + OrmTest.Demo.Filter.Init(); + OrmTest.Demo.MaterSlave.Init(); + OrmTest.Demo.ComplexModel.Init(); } } } diff --git a/SqlServerTest/UnitTest/ExpressionTest/Method.cs b/SqlServerTest/UnitTest/ExpressionTest/Method.cs index 16a435b19..0f56cc600 100644 --- a/SqlServerTest/UnitTest/ExpressionTest/Method.cs +++ b/SqlServerTest/UnitTest/ExpressionTest/Method.cs @@ -45,6 +45,7 @@ namespace OrmTest.UnitTest ToLower(); Trim(); Contains(); + Contains2(); ContainsArray(); StartsWith(); EndsWith(); @@ -416,6 +417,17 @@ namespace OrmTest.UnitTest new SugarParameter("@MethodConst0","a") }, "Contains error"); } + private void Contains2(string name="a") + { + Expression> 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() { + new SugarParameter("@MethodConst0","a") + }, "Contains2 error"); + } private void ExtendContainsArray() { string[] array = new string[] { "1", "2" }; diff --git a/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs b/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs index 64b5b111a..2d02654a2 100644 --- a/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs +++ b/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs @@ -148,6 +148,7 @@ namespace SqlSugar this.Context.Parameters.Add(new SugarParameter(parameterName, value)); } model.Args.Add(methodCallExpressionArgs); + parameter.ChildExpression = null; } private object GetMdthodValue(string name, MethodCallExpressionModel model)