修复代理问题

This commit is contained in:
橙子
2022-04-29 12:55:18 +08:00
parent 6c7b2224b1
commit 5d5c62123c
3 changed files with 2 additions and 8 deletions

View File

@@ -14,14 +14,13 @@ namespace Yi.Framework.Repository
/// <typeparam name="T"></typeparam>
public class Repository<T> : SimpleClient<T>, IRepository<T> where T : class, IBaseModelEntity, new()
{
public ISqlSugarClient _Db { get; set; }
public ISqlSugarClient _Db { get { return base.Context; } set { } }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="context"></param>
public Repository(ISqlSugarClient context) : base(context)//注意这里要有默认值等于null
{
_Db = context;
}
/// <summary>

View File

@@ -9,18 +9,13 @@ namespace Yi.Framework.Service
{
public partial class RoleService
{
private IRepository<RoleMenuEntity> _repositoryRoleMenu;
public RoleService(IRepository<RoleEntity> repository, IRepository<RoleMenuEntity> repositoryRoleMenu) : base(repository)
{
_repository = repository;
_repositoryRoleMenu = repositoryRoleMenu;
}
public async Task<List<RoleEntity>> DbTest()
{
return await _repository._Db.Queryable<RoleEntity>().ToListAsync();
}
public async Task<bool> GiveRoleSetMenu(List<long> roleIds, List<long> menuIds)
{
var _repositoryRoleMenu= _repository.ChangeRepository<Repository<RoleMenuEntity>>();
//多次操作,需要事务确保原子性
return await _repositoryRoleMenu.UseTranAsync(async () =>
{