Пример #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 CustomersRepository.GetAll().CountAsync(cancellationToken);

            return(DtoModelMapper.FromModelQueryToDtoQuery(_changeSetsRepository.GetAll(), parameters: new { customersCount = customersCount }));
        }
Пример #2
0
 public virtual async Task <IQueryable <TDto> > GetAll(CancellationToken cancellationToken)
 {
     return(DtoModelMapper.FromModelQueryToDtoQuery(await Repository.GetAllAsync(cancellationToken)));
 }
Пример #3
0
 public virtual IQueryable <TDto> GetAll()
 {
     return(DtoModelMapper.FromModelQueryToDtoQuery(Repository.GetAll()));
 }
Пример #4
0
        public override IQueryable <ChangeSetDto> GetAll()
        {
            IQueryable <Delivery> deliveriesQuery = DeliveriesRepository.GetAll();

            return(DtoModelMapper.FromModelQueryToDtoQuery(_changeSetsRepository.GetAll(), parameters: new { deliveriesQuery = deliveriesQuery }));
        }