mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 21:56:03 +08:00
Update MySql
This commit is contained in:
parent
dfe4f4c213
commit
20ec1bc3c4
@ -27,7 +27,7 @@ namespace OrmTest
|
|||||||
new AutoClose(1).Init();
|
new AutoClose(1).Init();
|
||||||
new Insert(1).Init();
|
new Insert(1).Init();
|
||||||
new Delete(1).Init();
|
new Delete(1).Init();
|
||||||
// new Update(1).Init();
|
new Update(1).Init();
|
||||||
// new Mapping(1).Init();
|
// new Mapping(1).Init();
|
||||||
// new DataTest(1).Init();
|
// new DataTest(1).Init();
|
||||||
|
|
||||||
|
@ -22,14 +22,14 @@ 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"
|
||||||
);
|
);
|
||||||
//use lock
|
//use lock
|
||||||
var t2 = db.Deleteable<Student>().With(SqlWith.RowLock).ToSql();
|
var t2 = db.Deleteable<Student>().With(SqlWith.RowLock).ToSql();
|
||||||
base.Check(@"DELETE FROM [STudent] WITH(ROWLOCK) ",
|
base.Check(@"DELETE FROM `STudent`",
|
||||||
null,
|
null,
|
||||||
t2.Key,
|
t2.Key,
|
||||||
null, "Delte t2 error"
|
null, "Delte t2 error"
|
||||||
@ -37,30 +37,30 @@ 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();
|
||||||
base.Check(@"DELETE FROM [STudent] WHERE ( [ID] = @Id0 ) ", new List<SugarParameter>() {
|
base.Check(@"DELETE FROM `STudent` WHERE ( `ID` = @Id0 ) ", new List<SugarParameter>() {
|
||||||
new SugarParameter("@Id0",1)
|
new SugarParameter("@Id0",1)
|
||||||
}, t5.Key, t5.Value, "Delte t5 error");
|
}, t5.Key, t5.Value, "Delte t5 error");
|
||||||
|
|
||||||
var t6 = db.Deleteable<Student>().Where("id=@id",new { id=1}).ToSql();
|
var t6 = db.Deleteable<Student>().Where("id=@id",new { id=1}).ToSql();
|
||||||
base.Check(@"DELETE FROM [STudent] WHERE id=@id", new List<SugarParameter>() {
|
base.Check(@"DELETE FROM `STudent` WHERE id=@id", new List<SugarParameter>() {
|
||||||
new SugarParameter("@id",1)
|
new SugarParameter("@id",1)
|
||||||
}, t6.Key, t6.Value, "Delte t6 error");
|
}, t6.Key, t6.Value, "Delte t6 error");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace SqlSugar
|
|||||||
foreach (var deleteObj in deleteObjs)
|
foreach (var deleteObj in deleteObjs)
|
||||||
{
|
{
|
||||||
var entityPropertyName = this.Context.EntityProvider.GetPropertyName<T>(primaryField);
|
var entityPropertyName = this.Context.EntityProvider.GetPropertyName<T>(primaryField);
|
||||||
var columnInfo = EntityInfo.Columns.Single(it => it.PropertyName == entityPropertyName);
|
var columnInfo = EntityInfo.Columns.Single(it => it.PropertyName.Equals(entityPropertyName,StringComparison.CurrentCultureIgnoreCase));
|
||||||
var value = columnInfo.PropertyInfo.GetValue(deleteObj, null);
|
var value = columnInfo.PropertyInfo.GetValue(deleteObj, null);
|
||||||
primaryKeyValues.Add(value);
|
primaryKeyValues.Add(value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user