Browse Source

-

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
ef67119868
  1. 2
      Src/Asp.Net/SqlServerTest/Program.cs
  2. 4
      Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Select.cs
  3. 13
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/UnaryExpressionResolve.cs

2
Src/Asp.Net/SqlServerTest/Program.cs

@ -18,7 +18,7 @@ namespace OrmTest
static void Main(string[] args)
{
// /***Unit Test***/
new Select(1).Init();
//new Select(1).Init();
new Field(1).Init();
new Where(1).Init();
new Method(1).Init();

4
Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Select.cs

@ -129,9 +129,9 @@ namespace OrmTest.UnitTest
"Select.single4 Error");
}
private void single5(int p = 1)
private void single5(DateTime? p = null)
{
Expression<Func<Student, object>> exp = it => it.SchoolId.HasValue;
Expression<Func<Student, object>> exp = it => p.HasValue;
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
expContext.IsSingle = false;
expContext.Resolve(exp, ResolveExpressType.WhereMultiple);

13
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/UnaryExpressionResolve.cs

@ -59,11 +59,16 @@ namespace SqlSugar
{
var member = memberExpression.Expression as MemberExpression;
parameter.CommonTempData = CommonTempDataType.Result;
this.Expression = member;
var isConst = member.Expression != null && member.Expression is ConstantExpression;
this.Expression = isConst?member.Expression:member;
this.Start();
var result= this.Context.DbMehtods.HasValue(new MethodCallExpressionModel() { Args=new List<MethodCallExpressionArgs>() {
new MethodCallExpressionArgs() { IsMember=true, MemberName= parameter.CommonTempData , MemberValue=null }
} });
var methodParamter = isConst ? new MethodCallExpressionArgs() { IsMember=false } : new MethodCallExpressionArgs() { IsMember = true, MemberName = parameter.CommonTempData, MemberValue = null };
var result = this.Context.DbMehtods.HasValue(new MethodCallExpressionModel()
{
Args = new List<MethodCallExpressionArgs>() {
methodParamter
}
});
this.Context.Result.Append(result);
parameter.CommonTempData = null;
}

Loading…
Cancel
Save