From d4e8ce9c89b19b499be24082b20b58fbffd24663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Mon, 30 Sep 2024 22:34:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/SqlSugarRepository.cs | 7 +++---- .../Uow/SqlSugarTransactionApi.cs | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Repositories/SqlSugarRepository.cs b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Repositories/SqlSugarRepository.cs index abf6de6b..082afb35 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Repositories/SqlSugarRepository.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Repositories/SqlSugarRepository.cs @@ -2,6 +2,7 @@ using System.Linq.Expressions; using System.Text; using Microsoft.Extensions.Logging; +using Nito.AsyncEx; using SqlSugar; using Volo.Abp; using Volo.Abp.Auditing; @@ -16,9 +17,9 @@ namespace Yi.Framework.SqlSugarCore.Repositories { public class SqlSugarRepository : ISqlSugarRepository, IRepository where TEntity : class, IEntity, new() { - public ISqlSugarClient _Db => GetDbContextAsync().Result; + public ISqlSugarClient _Db => AsyncContext.Run(async () => await GetDbContextAsync()); - public ISugarQueryable _DbQueryable => GetDbContextAsync().ConfigureAwait(false).GetAwaiter().GetResult().Queryable(); + public ISugarQueryable _DbQueryable => _Db.Queryable(); private ISugarDbContextProvider _sugarDbContextProvider; public IAsyncQueryableExecuter AsyncExecuter { get; } @@ -36,9 +37,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories /// public virtual async Task GetDbContextAsync() { - var db = (await _sugarDbContextProvider.GetDbContextAsync()).SqlSugarClient; - //await Console.Out.WriteLineAsync("获取的id:" + db.ContextID); return db; } diff --git a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Uow/SqlSugarTransactionApi.cs b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Uow/SqlSugarTransactionApi.cs index 6dea7007..05197e93 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Uow/SqlSugarTransactionApi.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Uow/SqlSugarTransactionApi.cs @@ -14,7 +14,6 @@ namespace Yi.Framework.SqlSugarCore.Uow public ISqlSugarDbContext GetDbContext() { - return _sqlsugarDbContext; }