Browse Source

-

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
483145f982
  1. 15
      OrmTest/ExpressionTest/Method.cs
  2. 11
      SqlSugar/ExpressionsToSql/ResolveItems/MemberNoExpressionResolve.cs
  3. 1
      SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

15
OrmTest/ExpressionTest/Method.cs

@ -24,6 +24,7 @@ namespace OrmTest.ExpressionTest
StringIsNullOrEmpty();
StringIsNullOrEmpty2();
StringIsNullOrEmpty3();
StringIsNullOrEmpty4();
}
base.End("Method Test");
}
@ -64,6 +65,20 @@ namespace OrmTest.ExpressionTest
new SugarParameter("@Id0",2)
}, "StringIsNullOrEmpty3");
}
private void StringIsNullOrEmpty4()
{
WhereConst.name = "xx";
Expression<Func<Student, bool>> exp = it => 2 == it.Id || NBORM.IsNullOrEmpty(WhereConst.name); ;
SqlServerExpressionContext expContext = new SqlServerExpressionContext(exp, ResolveExpressType.WhereSingle);
expContext.Resolve();
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "(( @Id0 = Id ) OR ( @MethodCost1='' OR @MethodCost1 IS NULL ))", new List<SugarParameter>() {
new SugarParameter("@MethodCost1","xx"),
new SugarParameter("@Id0",2)
}, "StringIsNullOrEmpty4");
}
}
}

11
SqlSugar/ExpressionsToSql/ResolveItems/MemberNoExpressionResolve.cs

@ -15,6 +15,8 @@ namespace SqlSugar
object value = null;
var isField = expression.Member is System.Reflection.FieldInfo;
var isProperty = expression.Member is System.Reflection.PropertyInfo;
var baseParameter = parameter.BaseParameter;
var isSetTempData = baseParameter.CommonTempData.IsValuable() && baseParameter.CommonTempData.Equals(CommonTempDataType.ChildNodeSet);
if (isField)
{
value = ExpressionTool.GetFiledValue(expression);
@ -26,10 +28,15 @@ namespace SqlSugar
switch (base.Context.ResolveType)
{
case ResolveExpressType.WhereSingle:
AppendParameter(parameter, isLeft, value);
break;
case ResolveExpressType.WhereMultiple:
if (isSetTempData)
{
baseParameter.CommonTempData = value;
}
else
{
AppendParameter(parameter, isLeft, value);
}
break;
case ResolveExpressType.SelectSingle:
break;

1
SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -23,6 +23,7 @@ namespace SqlSugar
case ResolveExpressType.WhereMultiple:
foreach (var item in args)
{
parameter.CommonTempData = CommonTempDataType.ChildNodeSet;
base.Expression = item;
base.Start();
var methodCallExpressionArgs = new MethodCallExpressionArgs()

Loading…
Cancel
Save