Update .net core project

This commit is contained in:
sunkaixuan
2022-08-23 20:43:38 +08:00
parent bdffac5d6a
commit 8f3f827d00
4 changed files with 20 additions and 4 deletions

View File

@@ -422,8 +422,9 @@ namespace SqlSugar
_WhereClassByPrimaryKey(new List<T>() { data });
return this;
}
public ISugarQueryable<T> TranLock(DbLockType LockType = DbLockType.Wait)
public ISugarQueryable<T> TranLock(DbLockType? LockType = DbLockType.Wait)
{
if (LockType == null) return this;
Check.ExceptionEasy(this.Context.Ado.Transaction == null, "need BeginTran", "需要事务才能使用TranLock");
Check.ExceptionEasy(this.QueryBuilder.IsSingle()==false, "TranLock, can only be used for single table query", "TranLock只能用在单表查询");
if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer)

View File

@@ -17,7 +17,9 @@ 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; }
private bool isDisableFilters = false;
public Storageable(List<T> datas, SqlSugarProvider context)
{
this.Context = context;
@@ -63,6 +65,17 @@ namespace SqlSugar
return this;
}
public IStorageable<T> DisableFilters()
{
this.isDisableFilters = true;
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 +127,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>().Filter(null, this.isDisableFilters).TranLock(this.lockType).AS(asname).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToList();
dbDataList.AddRange(addItems);
});
}
@@ -196,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).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

@@ -58,7 +58,7 @@ namespace SqlSugar
ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> columns);
ISugarQueryable<T> WhereColumns(Dictionary<string, object> columns, bool ignoreDefaultValue);
ISugarQueryable<T> WhereColumns(Dictionary<string, object> columns);
ISugarQueryable<T> TranLock(DbLockType LockType = DbLockType.Wait);
ISugarQueryable<T> TranLock(DbLockType? LockType = DbLockType.Wait);
ISugarQueryable<T> Where(Expression<Func<T, bool>> expression);
ISugarQueryable<T> Where(string whereString, object parameters = null);
ISugarQueryable<T> Where(List<IConditionalModel> conditionalModels);

View File

@@ -17,6 +17,8 @@ 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);
StorageableResult<T> ToStorage();