Browse Source

Update Demo

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
d9fa44b90d
  1. 14
      Src/Asp.NetCore/SqlServerTest/src/MySqlTest/UnitTest/ExpressionTest/Method.cs
  2. 2
      Src/Asp.NetCore/SqlServerTest/src/MySqlTest/UnitTest/Query/SingleQuery.cs
  3. 9
      Src/Asp.NetCore/SqlServerTest/src/MySqlTest/UnitTest/Update.cs

14
Src/Asp.NetCore/SqlServerTest/src/MySqlTest/UnitTest/ExpressionTest/Method.cs

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

2
Src/Asp.NetCore/SqlServerTest/src/MySqlTest/UnitTest/Query/SingleQuery.cs

@ -106,6 +106,8 @@ namespace OrmTest.UnitTest
.Select(it => new { it.Id, it.Name,x=it.Id }).ToSql(); .Select(it => new { it.Id, it.Name,x=it.Id }).ToSql();
base.Check("SELECT `ID` AS `Id` , `Name` AS `Name` , `ID` AS `x` FROM `STudent` WHERE `ID` IN (@InPara0) ", new List<SugarParameter>() { base.Check("SELECT `ID` AS `Id` , `Name` AS `Name` , `ID` AS `x` FROM `STudent` WHERE `ID` IN (@InPara0) ", new List<SugarParameter>() {
new SugarParameter("@InPara0",1) },t9.Key,t9.Value, "single t9 error"); new SugarParameter("@InPara0",1) },t9.Key,t9.Value, "single t9 error");
var t10 = db.Queryable<Student>().Select(it => new StudentEnum() { Id = SqlFunc.GetSelfAndAutoFill(it.Id) }).ToSql();
base.Check("SELECT * FROM `STudent` ", null, t10.Key, t10.Value, "single t10 error");
} }
} }

9
Src/Asp.NetCore/SqlServerTest/src/MySqlTest/UnitTest/Update.cs

@ -124,6 +124,15 @@ namespace OrmTest.UnitTest
t10.Value, t10.Value,
"Update 10 error" "Update 10 error"
); );
var t11 = db.Updateable<Student>(new Student() { Name="1", CreateTime=DateTime.Now.Date,SchoolId=1 }).WhereColumns(it => new { it.Name }).ToSql();
base.Check(@"UPDATE `STudent` SET
`SchoolId`=@SchoolId,`CreateTime`=@CreateTime WHERE `Name`=@Name", new List<SugarParameter>() {
new SugarParameter("@CreateTime",DateTime.Now.Date),
new SugarParameter("@Name","1"),
new SugarParameter("@SchoolId",1),
new SugarParameter("@ID",0)
}, t11.Key , t11.Value , "Update 11 error");
} }
public SqlSugarClient GetInstance() public SqlSugarClient GetInstance()

Loading…
Cancel
Save