diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UInsert.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UInsert.cs index 8036697aa..8b38a6d47 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UInsert.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UInsert.cs @@ -65,8 +65,8 @@ namespace OrmTest list2.First().Name = null; db.DbMaintenance.TruncateTable(); var x=Db.Storageable(list2) - .SplitInsert(it => !string.IsNullOrEmpty(it.Item.Name)) - .SplitUpdate(it => string.IsNullOrEmpty(it.Item.Name)) + //.SplitInsert(it => !string.IsNullOrEmpty(it.Item.Name)) + //.SplitUpdate(it => string.IsNullOrEmpty(it.Item.Name)) .SplitDelete(it=>it.Item.Id>10) .SplitIgnore(it=>it.Item.Id==2) .SplitError(it => it.Item.Id == 3,"id不能等于3") diff --git a/Src/Asp.Net/SqlSugar/Abstract/SaveableProvider/IStorageable.cs b/Src/Asp.Net/SqlSugar/Abstract/SaveableProvider/IStorageable.cs index 08244d7cc..4c7326391 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SaveableProvider/IStorageable.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SaveableProvider/IStorageable.cs @@ -62,10 +62,13 @@ namespace SqlSugar { if (this.datas.Count == 0) return new StorageableResult(); + var messageList = datas.Select(it => new StorageableMessage() { + Item=it.Item + }).ToList(); foreach (var item in whereFuncs.OrderByDescending(it => (int)it.key)) { - List> whereList = datas.Where(it => it.StorageType == null).ToList(); - Func, bool> exp = item.value1; + List> whereList = messageList.Where(it => it.StorageType == null).ToList(); + Func, bool> exp = item.value1; var list = whereList.Where(exp).ToList(); foreach (var it in list) { @@ -73,12 +76,12 @@ namespace SqlSugar it.StorageMessage = item.value2; } } - var delete = datas.Where(it => it.StorageType == StorageType.Delete).ToList(); - var update = datas.Where(it => it.StorageType == StorageType.Update).ToList(); - var inset = datas.Where(it => it.StorageType == StorageType.Insert).ToList(); - var error = datas.Where(it => it.StorageType == StorageType.Error).ToList(); - var ignore = datas.Where(it => it.StorageType == StorageType.Ignore||it.StorageType==null).ToList(); - var other = datas.Where(it => it.StorageType == StorageType.Other).ToList(); + var delete = messageList.Where(it => it.StorageType == StorageType.Delete).ToList(); + var update = messageList.Where(it => it.StorageType == StorageType.Update).ToList(); + var inset = messageList.Where(it => it.StorageType == StorageType.Insert).ToList(); + var error = messageList.Where(it => it.StorageType == StorageType.Error).ToList(); + var ignore = messageList.Where(it => it.StorageType == StorageType.Ignore||it.StorageType==null).ToList(); + var other = messageList.Where(it => it.StorageType == StorageType.Other).ToList(); StorageableResult result = new StorageableResult() { AsDeleteable = this.Context.Deleteable(delete.Select(it => it.Item).ToList()), @@ -90,7 +93,7 @@ namespace SqlSugar UpdateList = update, ErrorList = error, IgnoreList = ignore, - TotalList = datas + TotalList = messageList }; return result; } diff --git a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index edecfb3c0..47912e3b4 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -53,6 +53,10 @@ namespace SqlSugar public virtual int ExecuteCommand() { string sql = _ExecuteCommand(); + if (string.IsNullOrEmpty(sql)) + { + return 0; + } var result = this.Ado.ExecuteCommand(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray()); After(sql); return result; @@ -64,6 +68,10 @@ namespace SqlSugar public async Task ExecuteCommandAsync() { string sql = _ExecuteCommand(); + if (string.IsNullOrEmpty(sql)) + { + return 0; + } var result = await this.Ado.ExecuteCommandAsync(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray()); After(sql); return result; diff --git a/Src/Asp.Net/SqlSugar/Interface/IStorageable.cs b/Src/Asp.Net/SqlSugar/Interface/IStorageable.cs index 456f26c19..a855b40c8 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IStorageable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IStorageable.cs @@ -22,6 +22,10 @@ namespace SqlSugar { public T Item { get; set; } public List ExistData { get; set; } + } + + public class StorageableMessage : StorageableInfo where T : class, new() + { public string StorageMessage { get; set; } public StorageType? StorageType { get; set; } } @@ -50,13 +54,13 @@ namespace SqlSugar public class StorageableResult where T : class, new() { - public List> TotalList { get; set; } - public List> InsertList { get; set; } - public List> UpdateList { get; set; } - public List> DeleteList { get; set; } - public List> ErrorList { get; set; } - public List> IgnoreList { get; set; } - public List> OtherList { get; set; } + public List> TotalList { get; set; } + public List> InsertList { get; set; } + public List> UpdateList { get; set; } + public List> DeleteList { get; set; } + public List> ErrorList { get; set; } + public List> IgnoreList { get; set; } + public List> OtherList { get; set; } public IInsertable AsInsertable { get; set; } public IUpdateable AsUpdateable { get; set; } public IDeleteable AsDeleteable { get; set; }