Пример #1
0
        public override async Task <IQueryable <ChangeSetDto> > GetAll(CancellationToken cancellationToken)
        {
            // We can declare a view for following sql query in database and then map our dto directly to view using ef db context:
            // select *, (case (((select count(1) from Deliveries as Delivery where ChangeSet.Id = Delivery.ChangeSetId ))) when (select count(1) from Customers) then 1 else 0 end) as IsDeliveredToAll from ChangeSets as ChangeSet
            // or we can use ef core execute sql which returns IQueryable
            // Note: _changeSetsRepository.GetAll(changeSet => new ChangeSetDto { Id = changeSet.Id , ... , IsDeliveredToAll = changeSet.Deliveries.Count() == customersQuery.Count() }); results into problematic sql.

            // The downside of following code are its database round trips.

            int customersCount = await(await CustomersRepository.GetAllAsync(cancellationToken)).CountAsync(cancellationToken);

            return(DtoEntityMapper.FromEntityQueryToDtoQuery((await Repository.GetAllAsync(cancellationToken)), parameters: new { customersCount = customersCount }));
        }
Пример #2
0
 public virtual async Task <IQueryable <TDto> > GetAll(CancellationToken cancellationToken)
 {
     return(DtoEntityMapper.FromEntityQueryToDtoQuery(await Repository.GetAllAsync(cancellationToken).ConfigureAwait(false), membersToExpand: GetODataQueryOptions().GetExpandedProperties()));
 }
Пример #3
0
 public virtual async Task <IQueryable <TDto> > GetAll(CancellationToken cancellationToken)
 {
     return(DtoEntityMapper.FromEntityQueryToDtoQuery(await Repository.GetAllAsync(cancellationToken)));
 }
Пример #4
0
        public virtual async Task <SingleResult <CustomerDto> > GetCurrentCustomer(CancellationToken cancellationToken)
        {
            Guid customerId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            return(SingleResult.Create(DtoEntityMapper.FromEntityQueryToDtoQuery((await CustomersRepository.GetAllAsync(cancellationToken)).Where(c => c.Id == customerId))));
        }