Browse Source

-

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
6e4eb974a6
  1. BIN
      .vs/SqlSugar/v14/.suo
  2. 12
      OrmTest/ExpressionTest/Where.cs
  3. BIN
      OrmTest/bin/Debug/OrmTest.exe
  4. BIN
      OrmTest/bin/Debug/OrmTest.pdb
  5. BIN
      OrmTest/bin/Debug/SqlSugar.dll
  6. BIN
      OrmTest/bin/Debug/SqlSugar.pdb
  7. 39
      SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

BIN
.vs/SqlSugar/v14/.suo

Binary file not shown.

12
OrmTest/ExpressionTest/Where.cs

@ -27,9 +27,21 @@ namespace OrmTest.ExpressionTest
whereSingle4(); whereSingle4();
whereSingle5(); whereSingle5();
whereSingle6(); whereSingle6();
WhereMultiple1();
} }
base.End("Where Test"); base.End("Where Test");
} }
private void WhereMultiple1()
{
Expression<Func<Student, bool>> exp = it => it.Id > 1;
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.WhereMultiple);
expContext.Resolve();
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "( it.Id > @Id0 )", new List<SugarParameter>() {
new SugarParameter("@Id0",1)
}, "WhereMultiple1");
}
private void whereSingle1() private void whereSingle1()
{ {
Expression<Func<Student, bool>> exp = it => it.Id > 1; Expression<Func<Student, bool>> exp = it => it.Id > 1;

BIN
OrmTest/bin/Debug/OrmTest.exe

Binary file not shown.

BIN
OrmTest/bin/Debug/OrmTest.pdb

Binary file not shown.

BIN
OrmTest/bin/Debug/SqlSugar.dll

Binary file not shown.

BIN
OrmTest/bin/Debug/SqlSugar.pdb

Binary file not shown.

39
SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

@ -25,6 +25,27 @@ namespace SqlSugar
break; break;
case ResolveExpressType.WhereSingle: case ResolveExpressType.WhereSingle:
fieldName = getSingleName(parameter, expression, isLeft); fieldName = getSingleName(parameter, expression, isLeft);
fieldName = AppendMember(parameter, isLeft, fieldName);
break;
case ResolveExpressType.WhereMultiple:
fieldName = getMultipleName(parameter, expression, isLeft);
fieldName = AppendMember(parameter, isLeft, fieldName);
break;
case ResolveExpressType.FieldSingle:
fieldName = getSingleName(parameter, expression, isLeft);
base.Context.Result.Append(fieldName);
break;
case ResolveExpressType.FieldMultiple:
fieldName = getMultipleName(parameter, expression, isLeft);
base.Context.Result.Append(fieldName);
break;
default:
break;
}
}
private string AppendMember(ExpressionParameter parameter, bool? isLeft, string fieldName)
{
if (parameter.BaseExpression is BinaryExpression) if (parameter.BaseExpression is BinaryExpression)
{ {
fieldName = string.Format(" {0} ", fieldName); fieldName = string.Format(" {0} ", fieldName);
@ -45,22 +66,8 @@ namespace SqlSugar
{ {
base.Context.Result.Append(fieldName); base.Context.Result.Append(fieldName);
} }
break;
case ResolveExpressType.WhereMultiple: return fieldName;
fieldName = getMultipleName(parameter, expression, isLeft);
base.Context.Result.Append(fieldName);
break;
case ResolveExpressType.FieldSingle:
fieldName = getSingleName(parameter, expression, isLeft);
base.Context.Result.Append(fieldName);
break;
case ResolveExpressType.FieldMultiple:
fieldName = getMultipleName(parameter, expression, isLeft);
base.Context.Result.Append(fieldName);
break;
default:
break;
}
} }
private string getMultipleName(ExpressionParameter parameter, MemberExpression expression, bool? isLeft) private string getMultipleName(ExpressionParameter parameter, MemberExpression expression, bool? isLeft)

Loading…
Cancel
Save