Expression Bug

This commit is contained in:
sunkaixuan
2018-01-29 15:45:27 +08:00
parent b20c3aa183
commit 68c0435619
2 changed files with 19 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ namespace OrmTest.UnitTest
base.Begin(); base.Begin();
for (int i = 0; i < base.Count; i++) for (int i = 0; i < base.Count; i++)
{ {
whereSingle30();
whereSingle29("22"); whereSingle29("22");
whereSingle28(); whereSingle28();
whereSingle27(); whereSingle27();
@@ -57,6 +58,19 @@ namespace OrmTest.UnitTest
} }
base.End("Where Test"); base.End("Where Test");
} }
private void whereSingle30()
{
Expression<Func<Student, bool>> exp = it => it.Name == wc.name2;
ExpressionContext expContext = new ExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "( [Name] = @Name0 )", new List<SugarParameter>() {
new SugarParameter("@Name0","a")
}, "whereSingle30");
}
public string Get28(string a) { public string Get28(string a) {
return a + "1"; return a + "1";
} }
@@ -462,10 +476,12 @@ namespace OrmTest.UnitTest
}, "whereSingle25"); }, "whereSingle25");
} }
public static WhereConst wc = new WhereConst() { name2 = "a" };
} }
public class WhereConst public class WhereConst
{ {
public static string name { get; set; } public static string name { get; set; }
public string name2 { get; set; }
} }
} }

View File

@@ -109,6 +109,9 @@ namespace SqlSugar
} }
// fetch the root object reference: // fetch the root object reference:
var constExpr = expression as ConstantExpression; var constExpr = expression as ConstantExpression;
if (constExpr == null) {
return DynamicInvoke(rootExpression);
}
object objReference = constExpr.Value; object objReference = constExpr.Value;
// "ascend" back whence we came from and resolve object references along the way: // "ascend" back whence we came from and resolve object references along the way:
while (memberInfos.Count > 0) // or some other break condition while (memberInfos.Count > 0) // or some other break condition