在asp核心中无法通过Mediator从“ x”转换为“ INotification”

我需要在CQRS Mediator中使用通用INotification

我使用以下代码:

public class CreateCommand : INotification<OperationResult<CreateCommand>>
{
    public string email;

    public CreateCommand( string email)
    {
        this.email = email;
    }
}

public interface INotification<TEntity> : INotification
{
}

,在INotificationHandler中,我需要使用它:

INotificationHandler<OperationResult<CreateCommand>>

代码:

public class CreateUseractivetionCodeCommandHandler : 
    INotificationHandler<OperationResult<CreateCommand>>
{
    private readonly IEFDapperRepository<UseractivetionCode> repository;
    private readonly IEmailService email;

    public CreateUseractivetionCodeCommandHandler(
       IEFDapperRepository<UseractivetionCode> repository,IEmailService email)
    {
        this.repository = repository;
        this.email = email;
    }
}

但是它显示了这个错误:

  

严重性代码说明项目文件行抑制状态抑制状态   错误CS0311类型“ Travel.Common.Operation.OperationResult”不能用作通用类型或方法“ INotificationHandler”中的类型参数“ TNotification”。没有从“ Travel.Common.Operation.OperationResult”到“ MediatR.INotification”的隐式引用转换。 Travel.Services E:\ MyProject \ Trello \ Travel.Services \ UseractivetionCodeService \ Command \ Create \ CreateUseractivetionCodeCommandHandler.cs 16有效

出什么问题了?

cobol_12345 回答:在asp核心中无法通过Mediator从“ x”转换为“ INotification”

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3141221.html

大家都在问