Browse Source

Delete SqlSugarClient thread safety compatibility

pull/8/head
sunkaixuna 3 years ago
parent
commit
22a38a1c66
  1. 12
      Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/SubInserable.cs
  2. 47
      Src/Asp.Net/SqlSugar/SqlSugarClient.cs

12
Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/SubInserable.cs

@ -72,12 +72,22 @@ namespace SqlSugar
}
return resul;
}
[Obsolete("use ExecuteCommand")]
public object ExecuteReturnPrimaryKey()
{
return ExecuteCommand();
}
public async Task<object> ExecuteCommandAsync()
{
object resut = 0;
await Task.Run(() =>
{
resut= ExecuteCommand();
});
return resut;
}
public object ExecuteCommand()
{
var isNoTrean = this.Context.Ado.Transaction == null;
@ -126,7 +136,7 @@ namespace SqlSugar
return 0;
}
}
[Obsolete("use ExecuteCommandAsync")]
public Task<object> ExecuteReturnPrimaryKeyAsync()
{
return Task.FromResult(ExecuteReturnPrimaryKey());

47
Src/Asp.Net/SqlSugar/SqlSugarClient.cs

@ -826,32 +826,33 @@ namespace SqlSugar
{
result = NoSameThreadAndShard();
}
else if (IsSynchronization())
else
{
result = Synchronization();
}
else if (IsSingleInstanceAsync())
{
result = Synchronization();//Async no support Single Instance
}
else if (IsAsync())
{
result = Synchronization();
}
else
{
StackTrace st = new StackTrace(true);
var methods = st.GetFrames();
var isAsync = UtilMethods.IsAnyAsyncMethod(methods);
if (isAsync)
{
result = Synchronization();
}
else
{
result = NoSameThread();
}
}
///Because SqlSugarScope implements thread safety
//else if (IsSingleInstanceAsync())
//{
// result = Synchronization();//Async no support Single Instance
//}
//else if (IsAsync())
//{
// result = Synchronization();
//}
//else
//{
// StackTrace st = new StackTrace(true);
// var methods = st.GetFrames();
// var isAsync = UtilMethods.IsAnyAsyncMethod(methods);
// if (isAsync)
// {
// result = Synchronization();
// }
// else
// {
// result = NoSameThread();
// }
//}
if (result.Root == null)
{
result.Root = this;

Loading…
Cancel
Save