mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-23 12:33:44 +08:00
Update Core
This commit is contained in:
@@ -389,6 +389,27 @@ namespace SqlSugar
|
|||||||
_WhereClassByPrimaryKey(new List<T>() { data });
|
_WhereClassByPrimaryKey(new List<T>() { data });
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public ISugarQueryable<T> TranLock(DbLockType LockType = DbLockType.Wait)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (LockType == DbLockType.Wait)
|
||||||
|
{
|
||||||
|
this.With("UpdLock,RowLock");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.With("UpdLock,RowLock,NoWait");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.QueryBuilder.TranLock = (LockType == DbLockType.Error? " for update nowait" : " for update");
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> list)
|
public ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> list)
|
||||||
{
|
{
|
||||||
List<IConditionalModel> conditionalModels = new List<IConditionalModel>();
|
List<IConditionalModel> conditionalModels = new List<IConditionalModel>();
|
||||||
@@ -3323,6 +3344,7 @@ namespace SqlSugar
|
|||||||
_Size=it._Size
|
_Size=it._Size
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
asyncQueryableBuilder.TranLock = this.QueryBuilder.TranLock;
|
||||||
asyncQueryableBuilder.IsDisableMasterSlaveSeparation = this.QueryBuilder.IsDisableMasterSlaveSeparation;
|
asyncQueryableBuilder.IsDisableMasterSlaveSeparation = this.QueryBuilder.IsDisableMasterSlaveSeparation;
|
||||||
asyncQueryableBuilder.IsQueryInQuery = this.QueryBuilder.IsQueryInQuery;
|
asyncQueryableBuilder.IsQueryInQuery = this.QueryBuilder.IsQueryInQuery;
|
||||||
asyncQueryableBuilder.Includes = this.QueryBuilder.Includes;
|
asyncQueryableBuilder.Includes = this.QueryBuilder.Includes;
|
||||||
|
@@ -33,6 +33,7 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Splicing basic
|
#region Splicing basic
|
||||||
|
public string TranLock { get; set; }
|
||||||
public bool IsDisableMasterSlaveSeparation { get; set; }
|
public bool IsDisableMasterSlaveSeparation { get; set; }
|
||||||
public bool IsQueryInQuery { get; set; }
|
public bool IsQueryInQuery { get; set; }
|
||||||
public List<object> Includes { get; set; }
|
public List<object> Includes { get; set; }
|
||||||
|
14
Src/Asp.NetCore2/SqlSugar/Enum/DbLockType.cs
Normal file
14
Src/Asp.NetCore2/SqlSugar/Enum/DbLockType.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public enum DbLockType
|
||||||
|
{
|
||||||
|
Wait=0,
|
||||||
|
Error=1
|
||||||
|
}
|
||||||
|
}
|
@@ -54,6 +54,7 @@ namespace SqlSugar
|
|||||||
ISugarQueryable<T> WhereClassByPrimaryKey(List<T> list);
|
ISugarQueryable<T> WhereClassByPrimaryKey(List<T> list);
|
||||||
ISugarQueryable<T> WhereClassByPrimaryKey(T data) ;
|
ISugarQueryable<T> WhereClassByPrimaryKey(T data) ;
|
||||||
ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> columns);
|
ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> columns);
|
||||||
|
ISugarQueryable<T> TranLock(DbLockType LockType = DbLockType.Wait);
|
||||||
ISugarQueryable<T> Where(Expression<Func<T, bool>> expression);
|
ISugarQueryable<T> Where(Expression<Func<T, bool>> expression);
|
||||||
ISugarQueryable<T> Where(string whereString, object parameters = null);
|
ISugarQueryable<T> Where(string whereString, object parameters = null);
|
||||||
ISugarQueryable<T> Where(List<IConditionalModel> conditionalModels);
|
ISugarQueryable<T> Where(List<IConditionalModel> conditionalModels);
|
||||||
|
@@ -66,6 +66,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return "-- No table";
|
return "-- No table";
|
||||||
}
|
}
|
||||||
|
if (TranLock != null)
|
||||||
|
{
|
||||||
|
result = result + TranLock;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private string ToCountSqlString()
|
private string ToCountSqlString()
|
||||||
|
@@ -43,6 +43,10 @@ namespace SqlSugar
|
|||||||
result = this.Context.SqlQueryable<object>(result).Skip(Skip??0).Take(Take??0).ToSql().Key;
|
result = this.Context.SqlQueryable<object>(result).Skip(Skip??0).Take(Take??0).ToSql().Key;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if (TranLock != null)
|
||||||
|
{
|
||||||
|
result = result + TranLock;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ namespace SqlSugar
|
|||||||
columns.Add(dbColumnInfo);
|
columns.Add(dbColumnInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
columns = columns.OrderBy(it => it.IsPrimarykey ? 0 : 1).ToList();
|
||||||
this.Context.DbMaintenance.CreateTable(tableName, columns,true);
|
this.Context.DbMaintenance.CreateTable(tableName, columns,true);
|
||||||
}
|
}
|
||||||
protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
||||||
|
@@ -66,6 +66,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return "-- No table";
|
return "-- No table";
|
||||||
}
|
}
|
||||||
|
if (TranLock != null)
|
||||||
|
{
|
||||||
|
result = result + TranLock;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user