【发布时间】:2020-06-17 23:54:29
【问题描述】:
我从 CQRS 开始,我想我不太确定如何(或者是否可以这样做)添加一个可以对最终查询的结果进行过滤和排序的查询。 例如:
public partial class GetParticipantListQuery : IRequest<IList<ParticipantDto>>
{
public Expression<Func<ParticipantDto, bool>> Filter { get; set; } = null;
public Func<IQueryable<ParticipantDto>, IQueryable<ParticipantDto>> OrderBy { get; set; } = null;
}
然后在处理程序中将过滤和排序应用于数据库中的相应结果 这是一个不错的选择吗?我怎样才能在我的查询中实现这种事情? 我的目标是避免为我需要的每个过滤器创建一个查询,例如“GetParticipantsByNameQuery”、“GetParticipantsByTeamIdQuery”等等
【问题讨论】:
标签: c# .net-core entity-framework-core domain-driven-design cqrs