首页 > 解决方案 > 方面未触发 CQRS

问题描述

我的查询中有这样的功能,但除了句柄功能之外,我无法使用其他方面。不触发方面。我应该怎么办?我正在尝试使用 CQRS 模式来实现它。

    [ExceptionLogAspect(typeof(FileLogger))]
    public async Task<IDataResult<IEnumerable<PostDto>>> Handle(GetAllPostsQuery request, CancellationToken cancellationToken)
    {
        ....
    }

    [ExceptionLogAspect(typeof(FileLogger))]
    [SecuredOperation(Roles.Admin)]
    private async Task<IEnumerable<PostDto>> GetAllNotActivePosts()
    {
        ....
    }

    [ExceptionLogAspect(typeof(FileLogger))]
    private async Task<IEnumerable<PostDto>> GetAllActivePosts()
    {
         ....
    }
}

Autofac 模块

    builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces()
                    .AsClosedTypesOf(typeof(IRequestHandler<,>));

builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces()
                .EnableInterfaceInterceptors(new ProxyGenerationOptions
                {
                    Selector = new AspectInterceptorSelector()
                }).SingleInstance();

标签: c#asp.net-coreaopcqrsmediatr

解决方案


推荐阅读