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. 49
      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();
whereSingle5();
whereSingle6();
WhereMultiple1();
}
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()
{
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.

49
SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

@ -25,30 +25,11 @@ namespace SqlSugar
break;
case ResolveExpressType.WhereSingle:
fieldName = getSingleName(parameter, expression, isLeft);
if (parameter.BaseExpression is BinaryExpression)
{
fieldName = string.Format(" {0} ", fieldName);
if (isLeft == true)
{
fieldName += ExpressionConst.Format1 + parameter.BaseParameter.Index;
}
if (base.Context.Result.Contains(ExpressionConst.Format0))
{
base.Context.Result.Replace(ExpressionConst.Format0, fieldName);
}
else
{
base.Context.Result.Append(fieldName);
}
}
else
{
base.Context.Result.Append(fieldName);
}
fieldName = AppendMember(parameter, isLeft, fieldName);
break;
case ResolveExpressType.WhereMultiple:
fieldName = getMultipleName(parameter, expression, isLeft);
base.Context.Result.Append(fieldName);
fieldName = AppendMember(parameter, isLeft, fieldName);
break;
case ResolveExpressType.FieldSingle:
fieldName = getSingleName(parameter, expression, isLeft);
@ -63,6 +44,32 @@ namespace SqlSugar
}
}
private string AppendMember(ExpressionParameter parameter, bool? isLeft, string fieldName)
{
if (parameter.BaseExpression is BinaryExpression)
{
fieldName = string.Format(" {0} ", fieldName);
if (isLeft == true)
{
fieldName += ExpressionConst.Format1 + parameter.BaseParameter.Index;
}
if (base.Context.Result.Contains(ExpressionConst.Format0))
{
base.Context.Result.Replace(ExpressionConst.Format0, fieldName);
}
else
{
base.Context.Result.Append(fieldName);
}
}
else
{
base.Context.Result.Append(fieldName);
}
return fieldName;
}
private string getMultipleName(ExpressionParameter parameter, MemberExpression expression, bool? isLeft)
{
string shortName = expression.Expression.ToString();

Loading…
Cancel
Save