public override async Task <SingleValueResult <TModel> > HandleAsync(GetModelFromEntityByIdQuery <TModel, TEntity, TKey, TContext> request, CancellationToken cancellationToken = default)
        {
            var sourceSpecification = new EntityByIdSpecification <TEntity, TKey>(request.Key);
            var query = new SingleValueInquiry <TEntity, TModel>()
            {
                SourceSpecification = sourceSpecification
            };

            var result = await this.repository.RunQueryAsync(query, cancellationToken);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task Handle_SingleValueInquiry_Test()
        {
            using (var scope = this.provider.CreateScope())
            {
                var mediator = scope.ServiceProvider.GetRequiredService <IMediator>();
                var request  = new SingleValueInquiry <Source, Target>()
                {
                    SourceQuery = Array.Empty <Source>().AsQueryable()
                };
                var result = await mediator.HandleAsync(request, default);

                Assert.NotNull(result);
            }
        }