c# - 如何将实体传递给 MediatR(我尝试时遇到问题)
问题描述
我做了下面的类,但我有一个错误我想要做的是为所有查询创建一个通用类抛出 MediatR
这是我的课
public class GetAllBaseQuery<T> : IRequest<IResponseDTO>
where T :class
{
public class GetAllBaseQueryHandler<T> : IRequestHandler<GetAllBaseQuery<T>, IResponseDTO>
where T : class
{
private readonly IBaseResponse _Repo;
public GetAllBaseQueryHandler(IBaseResponse Repo)
{
_Repo = Repo;
}
public async Task<IResponseDTO> Handle(GetAllBaseQuery<T> query, CancellationToken cancellationToken)
{
var _rec= await _Repo.GetS<T>();
if (_rec== null)
{
return null;
}
return _rec;
}
}
}
这是错误信息
Register your handlers with the container. See the samples in GitHub for examples
解决方案
推荐阅读
- javascript - live-server:术语“live-server”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称
- javascript - 为什么 fetch().json() 错误不会触发 window.onerror?
- r - R:如何使用成对的开始、结束行序列序列创建 data.table 的动态子集
- python - 我想知道如何在Linux操作系统中使用Python设置时间
- javascript - ReactJS react-router-dom - 组件未显示
- ios - 如何从 appstoreconnect for iOS 应用程序中删除 macOS 应用程序页面版本
- android - Android Studio:添加 Google Places 依赖项失败
- r - 一起使用丛集和 kmeans 函数的问题 (R)
- android - CameraX 录制的视频分析图形错误
- python-3.x - Python中的客户细分