This commit is contained in:
sunkaixuan
2017-04-29 23:08:14 +08:00
parent 0ac6bf8419
commit 2cc4980231
5 changed files with 20 additions and 1 deletions

View File

@@ -44,7 +44,14 @@ namespace OrmTest.UnitTest
private void Between()
{
//throw new NotImplementedException();
Expression<Func<Student, bool>> exp = it => NBORM.Between(it.Name,1, 2);
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, " ([Name] BETWEEN @MethodConst0 AND @MethodConst1) ", new List<SugarParameter>() {
new SugarParameter("@MethodConst0",1),new SugarParameter("@MethodConst1",2),
}, "Between");
}
private void DateAddByType()

View File

@@ -74,5 +74,13 @@ namespace SqlSugar
var parameter2 = model.Args[1];
return string.Format(" (DATEADD(day,{1},{0})) ", parameter.Value, parameter2.Value);
}
public object Between(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
var parameter1 = model.Args[1];
var parameter2 = model.Args[2];
return string.Format(" ({0} BETWEEN {1} AND {2}) ", parameter.Value, parameter1.Value, parameter2.Value);
}
}
}

View File

@@ -21,5 +21,6 @@ namespace SqlSugar
object DateIsSameByType(MethodCallExpressionModel model);
object DateAddByType(MethodCallExpressionModel model);
object DateAddDay(MethodCallExpressionModel model);
object Between(MethodCallExpressionModel model);
}
}

View File

@@ -18,5 +18,6 @@ namespace SqlSugar
public static bool DateIsSame(DateTime date1, DateTime date2, DateType dataType) { throw new NotImplementedException(); }
public static bool DateAdd(DateTime date1, int addValue, DateType millisecond){ throw new NotImplementedException(); }
public static bool DateAdd(DateTime date1, int addValue) { throw new NotImplementedException(); }
public static bool Between(object value, object start, object end){ throw new NotImplementedException();}
}
}

View File

@@ -90,6 +90,8 @@ namespace SqlSugar
return this.Context.DbMehtods.DateAddDay(model);
else
return this.Context.DbMehtods.DateAddByType(model);
case "Between":
return this.Context.DbMehtods.Between(model);
default:
break;
}