提交 d1b09643 编写于 作者: lwplvx's avatar lwplvx

租户过滤生效(仅查询的时候)

上级 6ab69f5b
using System;
using Aurora.Common.Entities;
namespace Aurora.Core.Domain.Entities
{
......
using System;
using Aurora.Common.Entities;
namespace Aurora.Domain.Entities
namespace Aurora.Core.Domain.Entities
{
public class EntityBase:IEntity
{
......
using System;
using Aurora.Common.Entities;
namespace Aurora.Domain.Entities
namespace Aurora.Core.Domain.Entities
{
public class TenantEntityBase : EntityBase, ITenantEntity
{
......
......@@ -10,7 +10,6 @@ using System.Threading;
using System.Threading.Tasks;
using Aurora.Common.Entities;
using Aurora.Core.Domain.Entities;
using Aurora.Domain.Entities;
using Aurora.Infrastructure.Tenant;
using Aurora.Infrastructure.User;
using Microsoft.EntityFrameworkCore;
......@@ -19,14 +18,11 @@ namespace Aurora.Core.EntityFramework
{
public class ApplicationDbContext : DbContext
{
private readonly IUserContext currentUser;
private readonly ITenantContext currentTenant;
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options
, IUserContextProvider currentUserProvider,
ITenantContextProvider currentTenantProvider) : base(options)
,ITenantContextProvider currentTenantProvider) : base(options)
{
currentUser = currentUserProvider.GetUserContext();
currentTenant = currentTenantProvider.GetTenantContext();
}
......@@ -53,11 +49,12 @@ namespace Aurora.Core.EntityFramework
private static IList<Type> _baseEntityTypesCache;
private static IList<Type> GetBaseEntityTypes()
{
{
if (_baseEntityTypesCache != null)
return _baseEntityTypesCache.ToList();
// 包含了实体类的程序集
var assembly = typeof(TenantEntityBase).GetTypeInfo().Assembly;
// var assembly=Assembly.Load("Aurora.Core.Domain");
// var assembly=Assembly.Load("Aurora.Core.Domain");
_baseEntityTypesCache = (from t in assembly.DefinedTypes
where t.BaseType == typeof(TenantEntityBase)
select t.AsType()).ToList();
......
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -10,7 +6,6 @@ using System.Threading;
using System.Threading.Tasks;
using Aurora.Common.Entities;
using Aurora.Core.Domain.Entities;
using Aurora.Domain.Entities;
using Aurora.Infrastructure.Tenant;
using Aurora.Infrastructure.User;
using Microsoft.EntityFrameworkCore;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册