This commit is contained in:
sunkaixuan
2017-04-29 23:37:49 +08:00
parent b066e14927
commit 320c449ba1
5 changed files with 29 additions and 4 deletions

View File

@@ -39,11 +39,25 @@ namespace OrmTest.UnitTest
DateIsSameByType();
DateAddDay();
DateAddByType();
DateValue();
#endregion
}
base.End("Method Test");
}
private void DateValue()
{
var x2 = DateTime.Now;
Expression<Func<Student, bool>> exp = it => NBORM.DateValue(x2,DateType.Year);
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, " (@MethodConst1(@MethodConst0)) ", new List<SugarParameter>() {
new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",DateType.Year)
}, "StartsWith");
}
private void StartsWith()
{
Expression<Func<Student, bool>> exp = it => NBORM.StartsWith(it.Name, "a");

View File

@@ -96,5 +96,12 @@ namespace SqlSugar
var parameter2 = model.Args[1];
return string.Format(" ({0} like '%'+{1}) ", parameter.Value, parameter2.Value);
}
public object DateValue(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
var parameter2 = model.Args[1];
return string.Format(" ({0}({1})) ", parameter2.Value, parameter.Value);
}
}
}

View File

@@ -20,6 +20,7 @@ namespace SqlSugar
object DateIsSameDay(MethodCallExpressionModel model);
object DateIsSameByType(MethodCallExpressionModel model);
object DateAddByType(MethodCallExpressionModel model);
object DateValue(MethodCallExpressionModel model);
object DateAddDay(MethodCallExpressionModel model);
object Between(MethodCallExpressionModel model);
object StartsWith(MethodCallExpressionModel model);

View File

@@ -13,13 +13,14 @@ namespace SqlSugar
public static string ToUpper(object thisValue) { throw new NotImplementedException(); }
public static string Trim(object thisValue) { throw new NotImplementedException(); }
public static bool Contains(string thisValue, string parameterValue) { throw new NotImplementedException();}
public static bool StartsWith(string thisValue, string parameterValue) { throw new NotImplementedException(); }
public static bool EndsWith(string thisValue, string parameterValue) { throw new NotImplementedException(); }
public new static bool Equals(object thisValue, object parameterValue) { throw new NotImplementedException(); }
public static bool DateIsSame(DateTime date1, DateTime date2) { throw new NotImplementedException();}
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 DateAdd(DateTime date, int addValue, DateType millisecond){ throw new NotImplementedException(); }
public static bool DateAdd(DateTime date, int addValue) { throw new NotImplementedException(); }
public static bool DateValue(DateTime date, DateType dataType) { throw new NotImplementedException(); }
public static bool Between(object value, object start, object end){ throw new NotImplementedException();}
public static bool StartsWith(string thisValue, string parameterValue) { throw new NotImplementedException();}
public static bool EndsWith(string thisValue, string parameterValue) {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 "DateValue":
return this.Context.DbMehtods.DateValue(model);
case "Between":
return this.Context.DbMehtods.Between(model);
case "StartsWith":