Browse Source

Update Demo

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
f7c8191d27
  1. 4
      Src/Asp.Net/MySqlTest/Demos/1_Query.cs
  2. 14
      Src/Asp.Net/MySqlTest/UnitTest/ExpressionTest/Method.cs
  3. 8
      Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlExpressionContext.cs

4
Src/Asp.Net/MySqlTest/Demos/1_Query.cs

@ -181,6 +181,10 @@ namespace OrmTest.Demo
var getTodayList = db.Queryable<Student>().Where(it => SqlFunc.DateIsSame(it.CreateTime, DateTime.Now)).ToList();
var unionAll = db.UnionAll<Student>(db.Queryable<Student>(),db.Queryable<Student>());
var getDay1List = db.Queryable<Student>().Where(it => it.CreateTime.Value.Hour == 1).ToList();
var getDateAdd = db.Queryable<Student>().Where(it => it.CreateTime.Value.AddDays(1) == DateTime.Now).ToList();
var getDateIsSame = db.Queryable<Student>().Where(it => SqlFunc.DateIsSame(DateTime.Now, DateTime.Now, DateType.Hour)).ToList();
}
public static void Page()
{

14
Src/Asp.Net/MySqlTest/UnitTest/ExpressionTest/Method.cs

@ -272,8 +272,8 @@ namespace OrmTest.UnitTest
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, " ((@MethodConst1(@MethodConst0)) = @Const2 ) ", new List<SugarParameter>() {
new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",DateType.Year),new SugarParameter("@Const2",1)
base.Check(value, pars, " (Year(@MethodConst0) = @Const2 ) ", new List<SugarParameter>() {
new SugarParameter("@MethodConst0",x2),new SugarParameter("@Const2",1)
}, "DateValue error");
}
@ -319,9 +319,8 @@ namespace OrmTest.UnitTest
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "((DATE_ADD(@MethodConst1 INTERVAL @MethodConst2 @MethodConst0)) = @Const3 )", new List<SugarParameter>() {
new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",11),new SugarParameter("@Const3",x2),
new SugarParameter("@MethodConst2",DateType.Millisecond)
base.Check(value, pars, "((DATE_ADD(@MethodConst0 , INTERVAL @MethodConst1 Millisecond)) = @Const3 )", new List<SugarParameter>() {
new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",11),new SugarParameter("@Const3",x2)
}, "DateAddByType error");
}
private void DateAddDay()
@ -345,9 +344,8 @@ namespace OrmTest.UnitTest
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, " (TIMESTAMPDIFF(@MethodConst2,@MethodConst0,@MethodConst1)=0) ", new List<SugarParameter>() {
new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",x2),
new SugarParameter("@MethodConst2",DateType.Millisecond)
base.Check(value, pars, " (TIMESTAMPDIFF(Millisecond,@MethodConst0,@MethodConst1)=0) ", new List<SugarParameter>() {
new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",x2)
}, "DateIsSameByType error");
}
private void DateIsSameByDay()

8
Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlExpressionContext.cs

@ -54,6 +54,12 @@ namespace SqlSugar
}
public class MySqlMethod : DefaultDbMethod, IDbMethods
{
public override string DateValue(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
var parameter2 = model.Args[1];
return string.Format(" {0}({1}) ", parameter2.MemberValue, parameter.MemberName);
}
public override string Contains(MethodCallExpressionModel model)
{
@ -96,7 +102,7 @@ namespace SqlSugar
var parameter = model.Args[0];
var parameter2 = model.Args[1];
var parameter3 = model.Args[2];
return string.Format(" (DATE_ADD({1} INTERVAL {2} {0})) ", parameter.MemberName, parameter2.MemberName, parameter3.MemberValue);
return string.Format(" (DATE_ADD({1} , INTERVAL {2} {0})) ", parameter3.MemberValue, parameter.MemberName, parameter2.MemberName);
}
public override string DateAddDay(MethodCallExpressionModel model)

Loading…
Cancel
Save