mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 16:18:47 +08:00
Update db.Storageable
This commit is contained in:
parent
85015aa56f
commit
50728c26dc
@ -65,8 +65,8 @@ namespace OrmTest
|
|||||||
list2.First().Name = null;
|
list2.First().Name = null;
|
||||||
db.DbMaintenance.TruncateTable<UinitBlukTable>();
|
db.DbMaintenance.TruncateTable<UinitBlukTable>();
|
||||||
var x=Db.Storageable(list2)
|
var x=Db.Storageable(list2)
|
||||||
.SplitInsert(it => !string.IsNullOrEmpty(it.Item.Name))
|
//.SplitInsert(it => !string.IsNullOrEmpty(it.Item.Name))
|
||||||
.SplitUpdate(it => string.IsNullOrEmpty(it.Item.Name))
|
//.SplitUpdate(it => string.IsNullOrEmpty(it.Item.Name))
|
||||||
.SplitDelete(it=>it.Item.Id>10)
|
.SplitDelete(it=>it.Item.Id>10)
|
||||||
.SplitIgnore(it=>it.Item.Id==2)
|
.SplitIgnore(it=>it.Item.Id==2)
|
||||||
.SplitError(it => it.Item.Id == 3,"id不能等于3")
|
.SplitError(it => it.Item.Id == 3,"id不能等于3")
|
||||||
|
@ -62,10 +62,13 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (this.datas.Count == 0)
|
if (this.datas.Count == 0)
|
||||||
return new StorageableResult<T>();
|
return new StorageableResult<T>();
|
||||||
|
var messageList = datas.Select(it => new StorageableMessage<T>() {
|
||||||
|
Item=it.Item
|
||||||
|
}).ToList();
|
||||||
foreach (var item in whereFuncs.OrderByDescending(it => (int)it.key))
|
foreach (var item in whereFuncs.OrderByDescending(it => (int)it.key))
|
||||||
{
|
{
|
||||||
List<StorageableInfo<T>> whereList = datas.Where(it => it.StorageType == null).ToList();
|
List<StorageableMessage<T>> whereList = messageList.Where(it => it.StorageType == null).ToList();
|
||||||
Func<StorageableInfo<T>, bool> exp = item.value1;
|
Func<StorageableMessage<T>, bool> exp = item.value1;
|
||||||
var list = whereList.Where(exp).ToList();
|
var list = whereList.Where(exp).ToList();
|
||||||
foreach (var it in list)
|
foreach (var it in list)
|
||||||
{
|
{
|
||||||
@ -73,12 +76,12 @@ namespace SqlSugar
|
|||||||
it.StorageMessage = item.value2;
|
it.StorageMessage = item.value2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var delete = datas.Where(it => it.StorageType == StorageType.Delete).ToList();
|
var delete = messageList.Where(it => it.StorageType == StorageType.Delete).ToList();
|
||||||
var update = datas.Where(it => it.StorageType == StorageType.Update).ToList();
|
var update = messageList.Where(it => it.StorageType == StorageType.Update).ToList();
|
||||||
var inset = datas.Where(it => it.StorageType == StorageType.Insert).ToList();
|
var inset = messageList.Where(it => it.StorageType == StorageType.Insert).ToList();
|
||||||
var error = datas.Where(it => it.StorageType == StorageType.Error).ToList();
|
var error = messageList.Where(it => it.StorageType == StorageType.Error).ToList();
|
||||||
var ignore = datas.Where(it => it.StorageType == StorageType.Ignore||it.StorageType==null).ToList();
|
var ignore = messageList.Where(it => it.StorageType == StorageType.Ignore||it.StorageType==null).ToList();
|
||||||
var other = datas.Where(it => it.StorageType == StorageType.Other).ToList();
|
var other = messageList.Where(it => it.StorageType == StorageType.Other).ToList();
|
||||||
StorageableResult<T> result = new StorageableResult<T>()
|
StorageableResult<T> result = new StorageableResult<T>()
|
||||||
{
|
{
|
||||||
AsDeleteable = this.Context.Deleteable(delete.Select(it => it.Item).ToList()),
|
AsDeleteable = this.Context.Deleteable(delete.Select(it => it.Item).ToList()),
|
||||||
@ -90,7 +93,7 @@ namespace SqlSugar
|
|||||||
UpdateList = update,
|
UpdateList = update,
|
||||||
ErrorList = error,
|
ErrorList = error,
|
||||||
IgnoreList = ignore,
|
IgnoreList = ignore,
|
||||||
TotalList = datas
|
TotalList = messageList
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,10 @@ namespace SqlSugar
|
|||||||
public virtual int ExecuteCommand()
|
public virtual int ExecuteCommand()
|
||||||
{
|
{
|
||||||
string sql = _ExecuteCommand();
|
string sql = _ExecuteCommand();
|
||||||
|
if (string.IsNullOrEmpty(sql))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
var result = this.Ado.ExecuteCommand(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
var result = this.Ado.ExecuteCommand(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
||||||
After(sql);
|
After(sql);
|
||||||
return result;
|
return result;
|
||||||
@ -64,6 +68,10 @@ namespace SqlSugar
|
|||||||
public async Task<int> ExecuteCommandAsync()
|
public async Task<int> ExecuteCommandAsync()
|
||||||
{
|
{
|
||||||
string sql = _ExecuteCommand();
|
string sql = _ExecuteCommand();
|
||||||
|
if (string.IsNullOrEmpty(sql))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
var result = await this.Ado.ExecuteCommandAsync(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
var result = await this.Ado.ExecuteCommandAsync(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
||||||
After(sql);
|
After(sql);
|
||||||
return result;
|
return result;
|
||||||
|
@ -22,6 +22,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public T Item { get; set; }
|
public T Item { get; set; }
|
||||||
public List<T> ExistData { get; set; }
|
public List<T> ExistData { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StorageableMessage<T> : StorageableInfo<T> where T : class, new()
|
||||||
|
{
|
||||||
public string StorageMessage { get; set; }
|
public string StorageMessage { get; set; }
|
||||||
public StorageType? StorageType { get; set; }
|
public StorageType? StorageType { get; set; }
|
||||||
}
|
}
|
||||||
@ -50,13 +54,13 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public class StorageableResult<T> where T : class, new()
|
public class StorageableResult<T> where T : class, new()
|
||||||
{
|
{
|
||||||
public List<StorageableInfo<T>> TotalList { get; set; }
|
public List<StorageableMessage<T>> TotalList { get; set; }
|
||||||
public List<StorageableInfo<T>> InsertList { get; set; }
|
public List<StorageableMessage<T>> InsertList { get; set; }
|
||||||
public List<StorageableInfo<T>> UpdateList { get; set; }
|
public List<StorageableMessage<T>> UpdateList { get; set; }
|
||||||
public List<StorageableInfo<T>> DeleteList { get; set; }
|
public List<StorageableMessage<T>> DeleteList { get; set; }
|
||||||
public List<StorageableInfo<T>> ErrorList { get; set; }
|
public List<StorageableMessage<T>> ErrorList { get; set; }
|
||||||
public List<StorageableInfo<T>> IgnoreList { get; set; }
|
public List<StorageableMessage<T>> IgnoreList { get; set; }
|
||||||
public List<StorageableInfo<T>> OtherList { get; set; }
|
public List<StorageableMessage<T>> OtherList { get; set; }
|
||||||
public IInsertable<T> AsInsertable { get; set; }
|
public IInsertable<T> AsInsertable { get; set; }
|
||||||
public IUpdateable<T> AsUpdateable { get; set; }
|
public IUpdateable<T> AsUpdateable { get; set; }
|
||||||
public IDeleteable<T> AsDeleteable { get; set; }
|
public IDeleteable<T> AsDeleteable { get; set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user