mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-24 04:53:45 +08:00
Update db.Storageable
This commit is contained in:
@@ -41,7 +41,7 @@ namespace OrmTest
|
||||
x2.BulkCopy();
|
||||
x2.BulkUpdate();
|
||||
|
||||
var dt = db.Queryable<Order>().ToDataTable();
|
||||
var dt = db.Queryable<Order>().Take(1).ToDataTable();
|
||||
dt.TableName = "order";
|
||||
var addRow = dt.NewRow();
|
||||
addRow["id"] = 0;
|
||||
@@ -55,6 +55,13 @@ namespace OrmTest
|
||||
x3.AsInsertable.IgnoreColumns("id").ExecuteCommand();
|
||||
x3.AsUpdateable.ExecuteCommand();
|
||||
|
||||
|
||||
var x4 =
|
||||
db.Storageable(dt)
|
||||
.SplitDelete(it=>Convert.ToInt32( it["id"])>0)
|
||||
.WhereColumns("id").ToStorage();
|
||||
x4.AsDeleteable.ExecuteCommand();
|
||||
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("#### Saveable End ####");
|
||||
}
|
||||
|
@@ -242,6 +242,10 @@ namespace SqlSugar
|
||||
}
|
||||
public IDeleteable<T> Where(List<IConditionalModel> conditionalModels)
|
||||
{
|
||||
if (conditionalModels.Count == 0)
|
||||
{
|
||||
return Where("1=2");
|
||||
}
|
||||
var sql = this.Context.Queryable<T>().SqlBuilder.ConditionalModelToSql(conditionalModels);
|
||||
var result = this;
|
||||
result.Where(sql.Key, sql.Value);
|
||||
|
@@ -86,16 +86,22 @@ namespace SqlSugar
|
||||
{
|
||||
SplitMethod(item.value1,item.key,row,item.value2);
|
||||
}
|
||||
if (row[SugarGroupId] == null || row[SugarGroupId] == DBNull.Value)
|
||||
{
|
||||
row[SugarGroupId] = StorageType.Ignore;
|
||||
}
|
||||
}
|
||||
DataTable.Columns.Remove(SugarUpdateRows);
|
||||
DataTable.Columns.Remove(SugarColumns);
|
||||
var Groups=DataTable.Rows.Cast<DataRow>()
|
||||
.Where(it=> it[SugarGroupId]!=null&& it[SugarGroupId] != DBNull.Value)
|
||||
.GroupBy(it => ((StorageType)it[SugarGroupId]).ToString()).Select(it=>new DataTableGroups{ Type=it.Key,DataTable= it.CopyToDataTable() })
|
||||
.ToList();
|
||||
DataTable.Columns.Remove(SugarGroupId);
|
||||
DataTable.Columns.Remove(SugarErrorMessage);
|
||||
var inserList = new List<Dictionary<string, object>>();
|
||||
var updateList = new List<Dictionary<string, object>>();
|
||||
var DeleteList=Groups.FirstOrDefault(it=>it.Type==StorageType.Delete.ToString());
|
||||
if (Groups.Any(it => it.Type == StorageType.Insert.ToString()))
|
||||
{
|
||||
foreach (var item in Groups)
|
||||
@@ -120,11 +126,16 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IConditionalModel> conditionalModels = new List<IConditionalModel>();
|
||||
if (DeleteList!=null)
|
||||
{
|
||||
SetConditList(DeleteList.DataTable.Rows.Cast<DataRow>().ToList(), Columns, conditionalModels);
|
||||
}
|
||||
var tableName = this.Context.Queryable<object>().SqlBuilder.GetTranslationTableName(DataTable.TableName);
|
||||
DataTableResult result = new DataTableResult()
|
||||
{
|
||||
DataTableGroups=Groups,
|
||||
AsDeleteable=this.Context.Deleteable<object>().AS(tableName).Where(""),
|
||||
AsDeleteable=this.Context.Deleteable<object>().AS(tableName).Where(conditionalModels),
|
||||
AsUpdateable= this.Context.Updateable(updateList).AS(tableName).WhereColumns(Columns),
|
||||
AsInsertable=this.Context.Insertable(inserList).AS(tableName)
|
||||
};
|
||||
|
Reference in New Issue
Block a user