mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-16 21:19:34 +08:00
Add db.Storageable(data).TranLock
This commit is contained in:
parent
57f36a37a8
commit
c2d825e005
@ -17,6 +17,7 @@ namespace SqlSugar
|
||||
List<KeyValuePair<StorageType, Func<StorageableInfo<T>, bool>, string>> whereFuncs = new List<KeyValuePair<StorageType, Func<StorageableInfo<T>, bool>, string>>();
|
||||
Expression<Func<T, object>> whereExpression;
|
||||
Func<DateTime, string> formatTime;
|
||||
DbLockType? lockType;
|
||||
private string asname { get; set; }
|
||||
public Storageable(List<T> datas, SqlSugarProvider context)
|
||||
{
|
||||
@ -63,6 +64,11 @@ namespace SqlSugar
|
||||
return this;
|
||||
}
|
||||
|
||||
public IStorageable<T> TranLock(DbLockType dbLockType = DbLockType.Wait)
|
||||
{
|
||||
this.lockType = dbLockType;
|
||||
return this;
|
||||
}
|
||||
public IStorageable<T> SplitOther(Func<StorageableInfo<T>, bool> conditions, string message = null)
|
||||
{
|
||||
whereFuncs.Add(new KeyValuePair<StorageType, Func<StorageableInfo<T>, bool>, string>(StorageType.Other, conditions, message));
|
||||
@ -114,7 +120,7 @@ namespace SqlSugar
|
||||
if (whereExpression == null && pkInfos.Any())
|
||||
{
|
||||
this.Context.Utilities.PageEach(allDatas, 300, item => {
|
||||
var addItems=this.Context.Queryable<T>().AS(asname).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToList();
|
||||
var addItems=this.Context.Queryable<T>().TranLock(this.lockType).AS(asname).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToList();
|
||||
dbDataList.AddRange(addItems);
|
||||
});
|
||||
}
|
||||
@ -196,7 +202,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).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToListAsync();
|
||||
var addItems =await this.Context.Queryable<T>().AS(asname).TranLock(this.lockType).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToListAsync();
|
||||
dbDataList.AddRange(addItems);
|
||||
});
|
||||
}
|
||||
|
@ -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> 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);
|
||||
StorageableResult<T> ToStorage();
|
||||
|
Loading…
Reference in New Issue
Block a user