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; }