mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Asynchronous correlation processing
This commit is contained in:
@@ -391,6 +391,7 @@ namespace SqlSugar
|
||||
{
|
||||
try
|
||||
{
|
||||
Async();
|
||||
InitParameters(ref sql, parameters);
|
||||
if (FormatSql != null)
|
||||
sql = FormatSql(sql);
|
||||
@@ -422,6 +423,7 @@ namespace SqlSugar
|
||||
{
|
||||
try
|
||||
{
|
||||
Async();
|
||||
InitParameters(ref sql, parameters);
|
||||
if (FormatSql != null)
|
||||
sql = FormatSql(sql);
|
||||
@@ -452,6 +454,7 @@ namespace SqlSugar
|
||||
{
|
||||
try
|
||||
{
|
||||
Async();
|
||||
InitParameters(ref sql, parameters);
|
||||
if (FormatSql != null)
|
||||
sql = FormatSql(sql);
|
||||
@@ -482,6 +485,7 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual Task<DataSet> GetDataSetAllAsync(string sql, params SugarParameter[] parameters)
|
||||
{
|
||||
Async();
|
||||
//False asynchrony . No Support DataSet
|
||||
return Task.FromResult(GetDataSetAll(sql, parameters));
|
||||
}
|
||||
@@ -1152,17 +1156,13 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Helper
|
||||
//private static void NextResult(IDataReader dataReader)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// NextResult(dataReader);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // Check.Exception(true, ErrorMessage.GetThrowMessage("Please reduce the number of T. Save Queue Changes queries don't have so many results", "请减少T的数量,SaveQueueChanges 查询没有这么多结果"));
|
||||
// }
|
||||
//}
|
||||
private void Async()
|
||||
{
|
||||
if (this.Context.Root != null & this.Context.Root.AsyncId == null)
|
||||
{
|
||||
this.Context.Root.AsyncId = Guid.NewGuid(); ;
|
||||
}
|
||||
}
|
||||
private static bool NextResult(IDataReader dataReader)
|
||||
{
|
||||
try
|
||||
|
@@ -22,7 +22,7 @@ namespace SqlSugar
|
||||
_Context = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SqlSugarClient Root { get; set; }
|
||||
public ConnectionConfig CurrentConnectionConfig { get; set; }
|
||||
public Dictionary<string, object> TempItems { get { if (_TempItems == null) { _TempItems = new Dictionary<string, object>(); } return _TempItems; } set { _TempItems = value; } }
|
||||
public bool IsSystemTablesConfig { get { return this.CurrentConnectionConfig.InitKeyType == InitKeyType.SystemTable; } }
|
||||
|
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("5.0.0.7")]
|
||||
[assembly: AssemblyFileVersion("5.0.0.7")]
|
||||
[assembly: AssemblyVersion("5.0.0.8")]
|
||||
[assembly: AssemblyFileVersion("5.0.0.8")]
|
||||
|
@@ -22,6 +22,8 @@ namespace SqlSugar
|
||||
private MappingColumnList _MappingColumns;
|
||||
private IgnoreColumnList _IgnoreColumns;
|
||||
private IgnoreColumnList _IgnoreInsertColumns;
|
||||
internal Guid? AsyncId { get; set; }
|
||||
internal bool? IsSingeInstance { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -671,16 +673,44 @@ namespace SqlSugar
|
||||
#region Helper
|
||||
private SqlSugarProvider GetContext()
|
||||
{
|
||||
SqlSugarProvider result = null;
|
||||
if (IsSameThreadAndShard())
|
||||
return SameThreadAndShard();
|
||||
{
|
||||
result = SameThreadAndShard();
|
||||
}
|
||||
else if (IsNoSameThreadAndShard())
|
||||
return NoSameThreadAndShard();
|
||||
{
|
||||
result = NoSameThreadAndShard();
|
||||
}
|
||||
else if (IsSynchronization())
|
||||
return Synchronization();
|
||||
{
|
||||
result = Synchronization();
|
||||
}
|
||||
else if (IsInstanceAsync())
|
||||
{
|
||||
result = NoSameThreadAsync();
|
||||
}
|
||||
else if (IsAsync())
|
||||
{
|
||||
result = Synchronization();
|
||||
}
|
||||
else
|
||||
return NoSameThread();
|
||||
{
|
||||
IsSingeInstance = true;
|
||||
result = NoSameThread();
|
||||
}
|
||||
if (result.Root == null)
|
||||
{
|
||||
result.Root = this;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private SqlSugarProvider NoSameThreadAsync()
|
||||
{
|
||||
var result = GetCallContext();
|
||||
return result;
|
||||
}
|
||||
private SqlSugarProvider NoSameThread()
|
||||
{
|
||||
if (CallContext.ContextList.Value == null)
|
||||
@@ -761,6 +791,15 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsAsync()
|
||||
{
|
||||
return AsyncId != null;
|
||||
}
|
||||
|
||||
private bool IsInstanceAsync()
|
||||
{
|
||||
return IsSingeInstance == true && AsyncId != null;
|
||||
}
|
||||
|
||||
private bool IsSynchronization()
|
||||
{
|
||||
|
Reference in New Issue
Block a user