Add db.Storageable(data).DisableFilters()

This commit is contained in:
sunkaixuan
2022-08-23 20:25:00 +08:00
parent c2d825e005
commit bdffac5d6a
2 changed files with 10 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ namespace SqlSugar
Func<DateTime, string> formatTime;
DbLockType? lockType;
private string asname { get; set; }
private bool isDisableFilters = false;
public Storageable(List<T> datas, SqlSugarProvider context)
{
this.Context = context;
@@ -64,6 +65,12 @@ namespace SqlSugar
return this;
}
public IStorageable<T> DisableFilters()
{
this.isDisableFilters = true;
return this;
}
public IStorageable<T> TranLock(DbLockType dbLockType = DbLockType.Wait)
{
this.lockType = dbLockType;
@@ -120,7 +127,7 @@ namespace SqlSugar
if (whereExpression == null && pkInfos.Any())
{
this.Context.Utilities.PageEach(allDatas, 300, item => {
var addItems=this.Context.Queryable<T>().TranLock(this.lockType).AS(asname).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToList();
var addItems=this.Context.Queryable<T>().Filter(null, this.isDisableFilters).TranLock(this.lockType).AS(asname).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToList();
dbDataList.AddRange(addItems);
});
}
@@ -202,7 +209,7 @@ namespace SqlSugar
if (whereExpression == null && pkInfos.Any())
{
await this.Context.Utilities.PageEachAsync(allDatas, 300,async item => {
var addItems =await this.Context.Queryable<T>().AS(asname).TranLock(this.lockType).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToListAsync();
var addItems =await this.Context.Queryable<T>().Filter(null,this.isDisableFilters).AS(asname).TranLock(this.lockType).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToListAsync();
dbDataList.AddRange(addItems);
});
}

View File

@@ -17,6 +17,7 @@ namespace SqlSugar
IStorageable<T> Saveable(string inserMessage = null, string updateMessage = null);
IStorageable<T> SplitError(Func<StorageableInfo<T>, bool> conditions, string message = null);
IStorageable<T> SplitIgnore(Func<StorageableInfo<T>, bool> conditions, string message = null);
IStorageable<T> DisableFilters();
IStorageable<T> TranLock(DbLockType LockType = DbLockType.Wait);
IStorageable<T> SplitDelete(Func<StorageableInfo<T>, bool> conditions, string message = null);
IStorageable<T> SplitOther(Func<StorageableInfo<T>, bool> conditions, string message = null);