diff --git a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/SubInserable.cs b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/SubInserable.cs index 87545952f..230a54e78 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/SubInserable.cs +++ b/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 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 ExecuteReturnPrimaryKeyAsync() { return Task.FromResult(ExecuteReturnPrimaryKey()); diff --git a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs index 227c556ad..585fd69df 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs +++ b/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;