|
|
@ -27,7 +27,7 @@ namespace OrmTest.UnitTest |
|
|
|
base.Check(@"INSERT INTO `STudent`
|
|
|
|
(`SchoolId`,`Name`,`CreateTime`) |
|
|
|
VALUES |
|
|
|
(@SchoolId,@Name,@CreateTime) ;SELECT SCOPE_IDENTITY();",
|
|
|
|
(@SchoolId,@Name,@CreateTime) ;SELECT LAST_INSERT_ID();",
|
|
|
|
new List<SugarParameter>() { |
|
|
|
new SugarParameter("@SchoolId",0), |
|
|
|
new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")), |
|
|
@ -45,7 +45,7 @@ namespace OrmTest.UnitTest |
|
|
|
base.Check(@"INSERT INTO `STudent`
|
|
|
|
(`Name`) |
|
|
|
VALUES |
|
|
|
(@Name) ;SELECT SCOPE_IDENTITY();", new List<SugarParameter>() {
|
|
|
|
(@Name) ;SELECT LAST_INSERT_ID();", new List<SugarParameter>() {
|
|
|
|
new SugarParameter("@Name","jack") |
|
|
|
}, t3.Key, t3.Value, "Insert t3 error"); |
|
|
|
|
|
|
@ -55,7 +55,7 @@ namespace OrmTest.UnitTest |
|
|
|
base.Check(@"INSERT INTO `STudent`
|
|
|
|
(`SchoolId`,`CreateTime`) |
|
|
|
VALUES |
|
|
|
(@SchoolId,@CreateTime) ;SELECT SCOPE_IDENTITY();",
|
|
|
|
(@SchoolId,@CreateTime) ;SELECT LAST_INSERT_ID();",
|
|
|
|
new List<SugarParameter>() { |
|
|
|
new SugarParameter("@SchoolId",0), |
|
|
|
new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")), |
|
|
@ -64,10 +64,10 @@ namespace OrmTest.UnitTest |
|
|
|
|
|
|
|
//Ignore Name and TestId
|
|
|
|
var t5 = db.Insertable(insertObj).IgnoreColumns(it => it == "Name" || it == "TestId").With(SqlWith.UpdLock).ToSql(); |
|
|
|
base.Check(@"INSERT INTO `STudent` WITH(UPDLOCK)
|
|
|
|
base.Check(@"INSERT INTO `STudent`
|
|
|
|
(`SchoolId`,`CreateTime`) |
|
|
|
VALUES |
|
|
|
(@SchoolId,@CreateTime) ;SELECT SCOPE_IDENTITY();",
|
|
|
|
(@SchoolId,@CreateTime) ;SELECT LAST_INSERT_ID();",
|
|
|
|
new List<SugarParameter>() { |
|
|
|
new SugarParameter("@SchoolId",0), |
|
|
|
new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")), |
|
|
@ -75,10 +75,10 @@ new List<SugarParameter>() { |
|
|
|
); |
|
|
|
//Use Lock
|
|
|
|
var t6 = db.Insertable(insertObj).With(SqlWith.UpdLock).ToSql(); |
|
|
|
base.Check(@"INSERT INTO `STudent` WITH(UPDLOCK)
|
|
|
|
base.Check(@"INSERT INTO `STudent`
|
|
|
|
(`SchoolId`,`Name`,`CreateTime`) |
|
|
|
VALUES |
|
|
|
(@SchoolId,@Name,@CreateTime) ;SELECT SCOPE_IDENTITY();",
|
|
|
|
(@SchoolId,@Name,@CreateTime) ;SELECT LAST_INSERT_ID();",
|
|
|
|
new List<SugarParameter>() { |
|
|
|
new SugarParameter("@SchoolId",0), |
|
|
|
new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")), |
|
|
@ -91,7 +91,7 @@ new List<SugarParameter>() { |
|
|
|
base.Check(@"INSERT INTO `STudent`
|
|
|
|
(`ID`,`SchoolId`,`CreateTime`) |
|
|
|
VALUES |
|
|
|
(@ID,@SchoolId,@CreateTime) ;SELECT SCOPE_IDENTITY();",
|
|
|
|
(@ID,@SchoolId,@CreateTime) ;SELECT LAST_INSERT_ID();",
|
|
|
|
new List<SugarParameter>() { |
|
|
|
new SugarParameter("@SchoolId", 0), |
|
|
|
new SugarParameter("@ID", 0), |
|
|
@ -120,7 +120,7 @@ new List<SugarParameter>() { |
|
|
|
|
|
|
|
public SqlSugarClient GetInstance() |
|
|
|
{ |
|
|
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); |
|
|
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.MySql, IsAutoCloseConnection = true }); |
|
|
|
return db; |
|
|
|
} |
|
|
|
} |
|
|
|