Browse Source

Update Sqlite

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
0b5db835da
  1. 1
      Src/Asp.Net/SqlSugar/Realization/Sqlite/SqliteProvider.cs
  2. BIN
      Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite
  3. 6
      Src/Asp.Net/SqliteTest/UnitTest/Delete.cs
  4. 12
      Src/Asp.Net/SqliteTest/UnitTest/Insert.cs
  5. 12
      Src/Asp.Net/SqliteTest/UnitTest/Update.cs

1
Src/Asp.Net/SqlSugar/Realization/Sqlite/SqliteProvider.cs

@ -85,7 +85,6 @@ namespace SqlSugar
sqlParameter.Size = parameter.Size; sqlParameter.Size = parameter.Size;
sqlParameter.Value = parameter.Value; sqlParameter.Value = parameter.Value;
sqlParameter.DbType = parameter.DbType; sqlParameter.DbType = parameter.DbType;
sqlParameter.Direction = parameter.Direction;
result[index] = sqlParameter; result[index] = sqlParameter;
if (sqlParameter.Direction == ParameterDirection.Output) { if (sqlParameter.Direction == ParameterDirection.Output) {
if (this.OutputParameters == null) this.OutputParameters = new List<IDataParameter>(); if (this.OutputParameters == null) this.OutputParameters = new List<IDataParameter>();

BIN
Src/Asp.Net/SqliteTest/DataBase/SqlSugar4xTest.sqlite

Binary file not shown.

6
Src/Asp.Net/SqliteTest/UnitTest/Delete.cs

@ -22,7 +22,7 @@ namespace OrmTest
var db = GetInstance(); var db = GetInstance();
//by entity //by entity
var t1= db.Deleteable<Student>().Where(new Student() { Id = 1 }).ToSql(); var t1= db.Deleteable<Student>().Where(new Student() { Id = 1 }).ToSql();
base.Check(@"DELETE FROM `STudent` WHERE `ID` IN ('1') ", base.Check(@"DELETE FROM `STudent` WHERE `Id` IN ('1') ",
null, null,
t1.Key, t1.Key,
null, "Delte t1 error" null, "Delte t1 error"
@ -37,14 +37,14 @@ namespace OrmTest
//by primary key //by primary key
var t3 = db.Deleteable<Student>().In(1).ToSql(); var t3 = db.Deleteable<Student>().In(1).ToSql();
base.Check(@"DELETE FROM `STudent` WHERE `ID` IN ('1') ", base.Check(@"DELETE FROM `STudent` WHERE `Id` IN ('1') ",
null, null,
t3.Key, t3.Key,
null, "Delte tt error" null, "Delte tt error"
); );
//by primary key array //by primary key array
var t4 = db.Deleteable<Student>().In(new int[] { 1,2}).ToSql(); var t4 = db.Deleteable<Student>().In(new int[] { 1,2}).ToSql();
base.Check(@"DELETE FROM `STudent` WHERE `ID` IN ('1','2') ", null, t4.Key, null, "Update t4 error"); base.Check(@"DELETE FROM `STudent` WHERE `Id` IN ('1','2') ", null, t4.Key, null, "Update t4 error");
//by expression //by expression
var t5 = db.Deleteable<Student>().Where(it=>it.Id==1).ToSql(); var t5 = db.Deleteable<Student>().Where(it=>it.Id==1).ToSql();

12
Src/Asp.Net/SqliteTest/UnitTest/Insert.cs

@ -27,7 +27,7 @@ namespace OrmTest.UnitTest
base.Check(@"INSERT INTO `STudent` base.Check(@"INSERT INTO `STudent`
(`SchoolId`,`Name`,`CreateTime`) (`SchoolId`,`Name`,`CreateTime`)
VALUES VALUES
(@SchoolId,@Name,@CreateTime) ;SELECT LAST_INSERT_ID();", (@SchoolId,@Name,@CreateTime) ;SELECT LAST_INSERT_ROWID();",
new List<SugarParameter>() { new List<SugarParameter>() {
new SugarParameter("@SchoolId",0), new SugarParameter("@SchoolId",0),
new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")), new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")),
@ -45,7 +45,7 @@ namespace OrmTest.UnitTest
base.Check(@"INSERT INTO `STudent` base.Check(@"INSERT INTO `STudent`
(`Name`) (`Name`)
VALUES VALUES
(@Name) ;SELECT LAST_INSERT_ID();", new List<SugarParameter>() { (@Name) ;SELECT LAST_INSERT_ROWID();", new List<SugarParameter>() {
new SugarParameter("@Name","jack") new SugarParameter("@Name","jack")
}, t3.Key, t3.Value, "Insert t3 error"); }, t3.Key, t3.Value, "Insert t3 error");
@ -55,7 +55,7 @@ namespace OrmTest.UnitTest
base.Check(@"INSERT INTO `STudent` base.Check(@"INSERT INTO `STudent`
(`SchoolId`,`CreateTime`) (`SchoolId`,`CreateTime`)
VALUES VALUES
(@SchoolId,@CreateTime) ;SELECT LAST_INSERT_ID();", (@SchoolId,@CreateTime) ;SELECT LAST_INSERT_ROWID();",
new List<SugarParameter>() { new List<SugarParameter>() {
new SugarParameter("@SchoolId",0), new SugarParameter("@SchoolId",0),
new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")), new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")),
@ -67,7 +67,7 @@ namespace OrmTest.UnitTest
base.Check(@"INSERT INTO `STudent` base.Check(@"INSERT INTO `STudent`
(`SchoolId`,`CreateTime`) (`SchoolId`,`CreateTime`)
VALUES VALUES
(@SchoolId,@CreateTime) ;SELECT LAST_INSERT_ID();", (@SchoolId,@CreateTime) ;SELECT LAST_INSERT_ROWID();",
new List<SugarParameter>() { new List<SugarParameter>() {
new SugarParameter("@SchoolId",0), new SugarParameter("@SchoolId",0),
new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")), new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")),
@ -78,7 +78,7 @@ new List<SugarParameter>() {
base.Check(@"INSERT INTO `STudent` base.Check(@"INSERT INTO `STudent`
(`SchoolId`,`Name`,`CreateTime`) (`SchoolId`,`Name`,`CreateTime`)
VALUES VALUES
(@SchoolId,@Name,@CreateTime) ;SELECT LAST_INSERT_ID();", (@SchoolId,@Name,@CreateTime) ;SELECT LAST_INSERT_ROWID();",
new List<SugarParameter>() { new List<SugarParameter>() {
new SugarParameter("@SchoolId",0), new SugarParameter("@SchoolId",0),
new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")), new SugarParameter("@CreateTime",Convert.ToDateTime("2010-1-1")),
@ -91,7 +91,7 @@ new List<SugarParameter>() {
base.Check(@"INSERT INTO `STudent` base.Check(@"INSERT INTO `STudent`
(`ID`,`SchoolId`,`CreateTime`) (`ID`,`SchoolId`,`CreateTime`)
VALUES VALUES
(@ID,@SchoolId,@CreateTime) ;SELECT LAST_INSERT_ID();", (@ID,@SchoolId,@CreateTime) ;SELECT LAST_INSERT_ROWID();",
new List<SugarParameter>() { new List<SugarParameter>() {
new SugarParameter("@SchoolId", 0), new SugarParameter("@SchoolId", 0),
new SugarParameter("@ID", 0), new SugarParameter("@ID", 0),

12
Src/Asp.Net/SqliteTest/UnitTest/Update.cs

@ -26,7 +26,7 @@ namespace OrmTest.UnitTest
var t1 = db.Updateable(updateObj).ToSql(); var t1 = db.Updateable(updateObj).ToSql();
base.Check(@"UPDATE `STudent` SET base.Check(@"UPDATE `STudent` SET
`SchoolId`=@SchoolId,`Name`=@Name,`CreateTime`=@CreateTime WHERE `ID`=@ID", new List<SugarParameter>() { `SchoolId`=@SchoolId,`Name`=@Name,`CreateTime`=@CreateTime WHERE `Id`=@Id", new List<SugarParameter>() {
new SugarParameter("@SchoolId",0), new SugarParameter("@SchoolId",0),
new SugarParameter("@ID",1), new SugarParameter("@ID",1),
new SugarParameter("@CreateTime", Convert.ToDateTime("2017-05-21 09:56:12.610")), new SugarParameter("@CreateTime", Convert.ToDateTime("2017-05-21 09:56:12.610")),
@ -40,7 +40,7 @@ namespace OrmTest.UnitTest
//Only update Name //Only update Name
var t3 = db.Updateable(updateObj).UpdateColumns(it => new { it.Name }).ToSql(); var t3 = db.Updateable(updateObj).UpdateColumns(it => new { it.Name }).ToSql();
base.Check(@"UPDATE `STudent` SET base.Check(@"UPDATE `STudent` SET
`Name`=@Name WHERE `ID`=@ID", new List<SugarParameter>() { `Name`=@Name WHERE `Id`=@Id", new List<SugarParameter>() {
new SugarParameter("@ID",1), new SugarParameter("@ID",1),
new SugarParameter("@Name", "jack") new SugarParameter("@Name", "jack")
}, t3.Key, t3.Value, "Update t3 error"); }, t3.Key, t3.Value, "Update t3 error");
@ -48,7 +48,7 @@ namespace OrmTest.UnitTest
//Ignore Name and TestId //Ignore Name and TestId
var t4 = db.Updateable(updateObj).IgnoreColumns(it => new { it.Name, it.TestId }).ToSql(); var t4 = db.Updateable(updateObj).IgnoreColumns(it => new { it.Name, it.TestId }).ToSql();
base.Check(@"UPDATE `STudent` SET base.Check(@"UPDATE `STudent` SET
`SchoolId`=@SchoolId,`CreateTime`=@CreateTime WHERE `ID`=@ID", new List<SugarParameter>() { `SchoolId`=@SchoolId,`CreateTime`=@CreateTime WHERE `Id`=@Id", new List<SugarParameter>() {
new SugarParameter("@CreateTime",Convert.ToDateTime("2017-05-21 09:56:12.610")), new SugarParameter("@CreateTime",Convert.ToDateTime("2017-05-21 09:56:12.610")),
new SugarParameter("@SchoolId", 0), new SugarParameter("@SchoolId", 0),
new SugarParameter("@ID",1), new SugarParameter("@ID",1),
@ -57,7 +57,7 @@ namespace OrmTest.UnitTest
//Ignore Name and TestId //Ignore Name and TestId
var t5 = db.Updateable(updateObj).IgnoreColumns(it => it == "Name" || it == "TestId").With(SqlWith.UpdLock).ToSql(); var t5 = db.Updateable(updateObj).IgnoreColumns(it => it == "Name" || it == "TestId").With(SqlWith.UpdLock).ToSql();
base.Check(@"UPDATE `STudent` SET base.Check(@"UPDATE `STudent` SET
`SchoolId`=@SchoolId,`CreateTime`=@CreateTime WHERE `ID`=@ID", new List<SugarParameter>() { `SchoolId`=@SchoolId,`CreateTime`=@CreateTime WHERE `Id`=@Id", new List<SugarParameter>() {
new SugarParameter("@CreateTime",Convert.ToDateTime("2017-05-21 09:56:12.610")), new SugarParameter("@CreateTime",Convert.ToDateTime("2017-05-21 09:56:12.610")),
new SugarParameter("@SchoolId", 0), new SugarParameter("@SchoolId", 0),
new SugarParameter("@ID",1), new SugarParameter("@ID",1),
@ -67,7 +67,7 @@ namespace OrmTest.UnitTest
//Use Lock //Use Lock
var t6 = db.Updateable(updateObj).With(SqlWith.UpdLock).ToSql(); var t6 = db.Updateable(updateObj).With(SqlWith.UpdLock).ToSql();
base.Check(@"UPDATE `STudent` SET base.Check(@"UPDATE `STudent` SET
`SchoolId`=@SchoolId,`Name`=@Name,`CreateTime`=@CreateTime WHERE `ID`=@ID", new List<SugarParameter>() { `SchoolId`=@SchoolId,`Name`=@Name,`CreateTime`=@CreateTime WHERE `Id`=@Id", new List<SugarParameter>() {
new SugarParameter("@SchoolId",0), new SugarParameter("@SchoolId",0),
new SugarParameter("@ID",1), new SugarParameter("@ID",1),
new SugarParameter("@CreateTime", Convert.ToDateTime("2017-05-21 09:56:12.610")), new SugarParameter("@CreateTime", Convert.ToDateTime("2017-05-21 09:56:12.610")),
@ -91,7 +91,7 @@ namespace OrmTest.UnitTest
var t8 = db.Updateable(updateObj) var t8 = db.Updateable(updateObj)
.ReSetValue(it=>it.Name==(it.Name+1)).ToSql(); .ReSetValue(it=>it.Name==(it.Name+1)).ToSql();
base.Check(@"UPDATE `STudent` SET base.Check(@"UPDATE `STudent` SET
`SchoolId`=@SchoolId, `Name` =( `Name` + @Const0 ),`CreateTime`=@CreateTime WHERE `ID`=@ID", `SchoolId`=@SchoolId, `Name` =( `Name` + @Const0 ),`CreateTime`=@CreateTime WHERE `Id`=@Id",
new List<SugarParameter>() { new List<SugarParameter>() {
new SugarParameter("@SchoolId",0), new SugarParameter("@SchoolId",0),
new SugarParameter("@ID",1), new SugarParameter("@ID",1),

Loading…
Cancel
Save