mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
Update Unit Test
This commit is contained in:
@@ -124,6 +124,23 @@ new List<SugarParameter>() {
|
|||||||
(@Name) ;SELECT SCOPE_IDENTITY();", new List<SugarParameter>() {
|
(@Name) ;SELECT SCOPE_IDENTITY();", new List<SugarParameter>() {
|
||||||
new SugarParameter("@Name","张三")
|
new SugarParameter("@Name","张三")
|
||||||
}, t11.Key, t11.Value, "Insert t11 error");
|
}, t11.Key, t11.Value, "Insert t11 error");
|
||||||
|
|
||||||
|
|
||||||
|
var t12 = db.Insertable<Student>(new { Name = "a" }).ToSql();
|
||||||
|
base.Check(@"INSERT INTO [STudent]
|
||||||
|
([Name])
|
||||||
|
VALUES
|
||||||
|
(@Name) ;SELECT SCOPE_IDENTITY();", new List<SugarParameter>() {
|
||||||
|
new SugarParameter("@Name","a")
|
||||||
|
}, t12.Key, t12.Value, "Insert t12 error");
|
||||||
|
|
||||||
|
var t13 = db.Insertable<Student>(new Dictionary<string, object>() { {"id",0 },{ "name","2"} }).ToSql();
|
||||||
|
base.Check(@"INSERT INTO [STudent]
|
||||||
|
([Name])
|
||||||
|
VALUES
|
||||||
|
(@Name) ;SELECT SCOPE_IDENTITY();", new List<SugarParameter>() {
|
||||||
|
new SugarParameter("@Name","2")
|
||||||
|
}, t13.Key, t13.Value, "Insert t13 error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -144,6 +144,21 @@ namespace OrmTest.UnitTest
|
|||||||
"Update 12 error"
|
"Update 12 error"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var t13 = db.Updateable<Student>(new { Name = "a", id=1 }).ToSql();
|
||||||
|
base.Check(@"UPDATE [STudent] SET
|
||||||
|
[Name]=@Name WHERE [Id]=@Id", new List<SugarParameter>() {
|
||||||
|
new SugarParameter("@Name","a"),
|
||||||
|
new SugarParameter("@ID",1)
|
||||||
|
}, t13.Key, t13.Value, "Insert t13 error");
|
||||||
|
|
||||||
|
var t14 = db.Updateable<Student>(new Dictionary<string, object>() { { "id", 0 }, { "name", "2" } }).ToSql();
|
||||||
|
base.Check(@"UPDATE [STudent] SET
|
||||||
|
[Name]=@Name WHERE [Id]=@Id", new List<SugarParameter>() {
|
||||||
|
new SugarParameter("@Name", "2"),
|
||||||
|
new SugarParameter("@ID", 0)
|
||||||
|
}, t14.Key, t14.Value, "Insert t14 error");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -265,7 +265,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Insertable.columnDictionary can't be null");
|
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Insertable.columnDictionary can't be null");
|
||||||
var insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary));
|
var insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary));
|
||||||
return this.Insertable(insertObject);
|
var columns = columnDictionary.Select(it => it.Key).ToList();
|
||||||
|
return this.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c,StringComparison.CurrentCultureIgnoreCase))); ;
|
||||||
}
|
}
|
||||||
public virtual IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new()
|
public virtual IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new()
|
||||||
{
|
{
|
||||||
@@ -275,8 +276,9 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(insertDynamicObject));
|
var columns= ((object)insertDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
|
||||||
return this.Insertable(insertObject);
|
T insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(insertDynamicObject));
|
||||||
|
return this.Insertable(insertObject).InsertColumns(it=> columns.Any(c=>it.Equals(c,StringComparison.CurrentCultureIgnoreCase)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -338,7 +340,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Updateable.columnDictionary can't be null");
|
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Updateable.columnDictionary can't be null");
|
||||||
var updateObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary));
|
var updateObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary));
|
||||||
return this.Updateable(updateObject);
|
var columns = columnDictionary.Select(it => it.Key).ToList();
|
||||||
|
return this.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
|
||||||
}
|
}
|
||||||
public virtual IUpdateable<T> Updateable<T>(dynamic updateDynamicObject) where T : class, new()
|
public virtual IUpdateable<T> Updateable<T>(dynamic updateDynamicObject) where T : class, new()
|
||||||
{
|
{
|
||||||
@@ -348,8 +351,9 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var updateObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(updateDynamicObject));
|
var columns = ((object)updateDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
|
||||||
return this.Updateable(updateObject);
|
T updateObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(updateDynamicObject));
|
||||||
|
return this.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
Reference in New Issue
Block a user