mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
ok
This commit is contained in:
parent
a3cdbad4fd
commit
98e4bc7e35
Binary file not shown.
@ -25,6 +25,7 @@ namespace OrmTest.ExpressionTest
|
||||
whereSingle2();
|
||||
whereSingle3();
|
||||
whereSingle4();
|
||||
whereSingle5();
|
||||
}
|
||||
base.End("Where Test");
|
||||
}
|
||||
@ -76,5 +77,25 @@ namespace OrmTest.ExpressionTest
|
||||
new SugarParameter("@Name2","a1")
|
||||
}, "whereSingle4");
|
||||
}
|
||||
private void whereSingle5()
|
||||
{
|
||||
string name = "a";
|
||||
WhereConst.name = "a1";
|
||||
Expression<Func<Student, bool>> exp = it => (it.Id > 1 && it.Name != name) || it.Name == WhereConst.name;
|
||||
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.WhereSingle);
|
||||
expContext.Resolve();
|
||||
var value = expContext.Result.GetString();
|
||||
var pars = expContext.Parameters;
|
||||
base.Check(value, pars, " ((( Id > @Id0 ) AND ( Name <> @Name1 )) OR ( Name = @Name2 )) ", new List<SugarParameter>() {
|
||||
new SugarParameter("@Id0",1),
|
||||
new SugarParameter("@Name1","a"),
|
||||
new SugarParameter("@Name2","a1")
|
||||
}, "whereSingle4");
|
||||
}
|
||||
}
|
||||
|
||||
public class WhereConst
|
||||
{
|
||||
public static string name { get; set; }
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -21,6 +21,36 @@ namespace SqlSugar
|
||||
parameter.BaseParameter.CommonTempData = value;
|
||||
break;
|
||||
case ResolveExpressType.WhereSingle:
|
||||
if (parameter.BaseExpression is BinaryExpression)
|
||||
{
|
||||
var otherExpression = isLeft == true ? parameter.BaseParameter.RightExpression : parameter.BaseParameter.LeftExpression;
|
||||
if (otherExpression is MemberExpression)
|
||||
{
|
||||
string parameterName = Context.SqlParameterKeyWord
|
||||
+ ((MemberExpression)otherExpression).Member.Name
|
||||
+ Context.ParameterIndex;
|
||||
base.Context.Parameters.Add(new SugarParameter(parameterName, value));
|
||||
Context.ParameterIndex++;
|
||||
parameterName = string.Format(" {0} ", parameterName);
|
||||
if (isLeft == true)
|
||||
{
|
||||
parameterName += ExpressionConst.Format1 + parameter.BaseParameter.Index;
|
||||
}
|
||||
if (base.Context.Result.Contains(ExpressionConst.Format0))
|
||||
{
|
||||
base.Context.Result.Replace(ExpressionConst.Format0, parameterName);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Context.Result.Append(parameterName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ResolveExpressType.WhereMultiple:
|
||||
case ResolveExpressType.FieldSingle:
|
||||
case ResolveExpressType.FieldMultiple:
|
||||
|
Loading…
Reference in New Issue
Block a user