Пример #1
0
        public RegionCollectionResponse Fetch(RegionQueryCollectionRequest request)
        {
            base.FixupLimitAndPagingOnRequest(request);

            var totalItemCount  = 0;
            var sortExpression  = RepositoryHelper.ConvertStringToSortExpression(EntityType, request.Sort);
            var includeFields   = RepositoryHelper.ConvertStringToExcludedIncludedFields(EntityType, request.Select);
            var prefetchPath    = RepositoryHelper.ConvertStringToPrefetchPath(EntityType, request.Include, request.Select);
            var predicateBucket = RepositoryHelper.ConvertStringToRelationPredicateBucket(EntityType, request.Filter, request.Relations);

            EntityCollection <RegionEntity> entities;

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                OnBeforeFetchRegionQueryCollectionRequest(adapter, request, sortExpression, includeFields, prefetchPath, predicateBucket,
                                                          request.PageNumber, request.PageSize, request.Limit);
                entities = base.Fetch(adapter, sortExpression, includeFields, prefetchPath, predicateBucket,
                                      request.PageNumber, request.PageSize, request.Limit, request.RCache, out totalItemCount);
                OnAfterFetchRegionQueryCollectionRequest(adapter, request, entities, sortExpression, includeFields, prefetchPath, predicateBucket,
                                                         request.PageNumber, request.PageSize, request.Limit, totalItemCount);
            }
            var response = new RegionCollectionResponse(entities.ToDtoCollection(), request.PageNumber,
                                                        request.PageSize, totalItemCount);

            return(response);
        }
Пример #2
0
        public EmployeesByRegionAndTerritoryCollectionResponse Fetch(EmployeesByRegionAndTerritoryQueryCollectionRequest request)
        {
            base.FixupLimitAndPagingOnRequest(request);

            var typedList = new EmployeesByRegionAndTerritoryTypedList();

            var totalItemCount     = 0;
            var sortExpression     = RepositoryHelper.ConvertStringToSortExpression(TypedListType, request.Sort);
            var includedFieldNames = RepositoryHelper.ConvertStringToExcludedIncludedFields(request.Select);
            var predicateBucket    = RepositoryHelper.ConvertStringToRelationPredicateBucket(TypedListType, typedList.GetRelationInfo(), request.Filter);

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                OnBeforeFetchEmployeesByRegionAndTerritoryQueryCollectionRequest(adapter, request, sortExpression, includedFieldNames, predicateBucket,
                                                                                 request.PageNumber, request.PageSize, request.Limit);
                totalItemCount = (int)adapter.GetDbCount(typedList.GetFieldsInfo(), predicateBucket, null, false);
                adapter.FetchTypedList(typedList.GetFieldsInfo(), typedList, predicateBucket, request.Limit, sortExpression, true, null, request.PageNumber, request.PageSize);
                OnAfterFetchEmployeesByRegionAndTerritoryQueryCollectionRequest(adapter, request, typedList, sortExpression, includedFieldNames, predicateBucket,
                                                                                request.PageNumber, request.PageSize, request.Limit, totalItemCount);
            }

            var dtos       = new EmployeesByRegionAndTerritoryCollection();
            var enumerator = typedList.GetEnumerator();

            while (enumerator.MoveNext())
            {
                dtos.Add(Map(enumerator.Current, includedFieldNames));
            }

            var response = new EmployeesByRegionAndTerritoryCollectionResponse(dtos, request.PageNumber,
                                                                               request.PageSize, totalItemCount);

            return(response);
        }
        public CustomerDemographicResponse Fetch(CustomerDemographicPkRequest request)
        {
            var entity = new CustomerDemographicEntity();

            entity.CustomerTypeId = request.CustomerTypeId;

            var excludedIncludedFields = RepositoryHelper.ConvertStringToExcludedIncludedFields(EntityType, request.Select);
            var prefetchPath           = RepositoryHelper.ConvertStringToPrefetchPath(EntityType, request.Include, request.Select);

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                OnBeforeFetchCustomerDemographicPkRequest(adapter, request, entity, prefetchPath, excludedIncludedFields);
                if (adapter.FetchEntity(entity, prefetchPath, null, excludedIncludedFields))
                {
                    OnAfterFetchCustomerDemographicPkRequest(adapter, request, entity, prefetchPath, excludedIncludedFields);
                    return(new CustomerDemographicResponse(entity.ToDto()));
                }
            }
            return(new CustomerDemographicResponse(null));
        }
        public SupplierResponse Fetch(SupplierUcSupplierNameRequest request)
        {
            var entity = new SupplierEntity();

            entity.CompanyName = request.CompanyName;

            var excludedIncludedFields = RepositoryHelper.ConvertStringToExcludedIncludedFields(EntityType, request.Select);
            var prefetchPath           = RepositoryHelper.ConvertStringToPrefetchPath(EntityType, request.Include, request.Select);

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                var predicate = entity.ConstructFilterForUCCompanyName();
                OnBeforeFetchSupplierUcSupplierNameRequest(adapter, request, entity, predicate, prefetchPath, excludedIncludedFields);
                if (adapter.FetchEntityUsingUniqueConstraint(entity, predicate, prefetchPath, null, excludedIncludedFields))
                {
                    OnAfterFetchSupplierUcSupplierNameRequest(adapter, request, entity, predicate, prefetchPath, excludedIncludedFields);
                    return(new SupplierResponse(entity.ToDto()));
                }
            }
            return(new SupplierResponse(null));
        }
Пример #5
0
        public RegionResponse Fetch(RegionUcRegionDescriptionRequest request)
        {
            var entity = new RegionEntity();

            entity.RegionDescription = request.RegionDescription;

            var excludedIncludedFields = RepositoryHelper.ConvertStringToExcludedIncludedFields(EntityType, request.Select);
            var prefetchPath           = RepositoryHelper.ConvertStringToPrefetchPath(EntityType, request.Include, request.Select);

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                var predicate = entity.ConstructFilterForUCRegionDescription();
                OnBeforeFetchRegionUcRegionDescriptionRequest(adapter, request, entity, predicate, prefetchPath, excludedIncludedFields);
                if (adapter.FetchEntityUsingUniqueConstraint(entity, predicate, prefetchPath, null, excludedIncludedFields))
                {
                    OnAfterFetchRegionUcRegionDescriptionRequest(adapter, request, entity, predicate, prefetchPath, excludedIncludedFields);
                    return(new RegionResponse(entity.ToDto()));
                }
            }
            return(new RegionResponse(null));
        }
Пример #6
0
        public OrderDetailResponse Fetch(OrderDetailPkRequest request)
        {
            var entity = new OrderDetailEntity();

            entity.OrderId   = request.OrderId;
            entity.ProductId = request.ProductId;

            var excludedIncludedFields = RepositoryHelper.ConvertStringToExcludedIncludedFields(EntityType, request.Select);
            var prefetchPath           = RepositoryHelper.ConvertStringToPrefetchPath(EntityType, request.Include, request.Select);

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                OnBeforeFetchOrderDetailPkRequest(adapter, request, entity, prefetchPath, excludedIncludedFields);
                if (adapter.FetchEntity(entity, prefetchPath, null, excludedIncludedFields))
                {
                    OnAfterFetchOrderDetailPkRequest(adapter, request, entity, prefetchPath, excludedIncludedFields);
                    return(new OrderDetailResponse(entity.ToDto()));
                }
            }
            return(new OrderDetailResponse(null));
        }
        public EmployeeTerritoryResponse Fetch(EmployeeTerritoryPkRequest request)
        {
            var entity = new EmployeeTerritoryEntity();

            entity.EmployeeId  = request.EmployeeId;
            entity.TerritoryId = request.TerritoryId;

            var excludedIncludedFields = RepositoryHelper.ConvertStringToExcludedIncludedFields(EntityType, request.Select);
            var prefetchPath           = RepositoryHelper.ConvertStringToPrefetchPath(EntityType, request.Include, request.Select);

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                OnBeforeFetchEmployeeTerritoryPkRequest(adapter, request, entity, prefetchPath, excludedIncludedFields);
                if (adapter.FetchEntity(entity, prefetchPath, null, excludedIncludedFields))
                {
                    OnAfterFetchEmployeeTerritoryPkRequest(adapter, request, entity, prefetchPath, excludedIncludedFields);
                    return(new EmployeeTerritoryResponse(entity.ToDto()));
                }
            }
            return(new EmployeeTerritoryResponse(null));
        }
Пример #8
0
        public RegionResponse Fetch(RegionPkRequest request)
        {
            var entity = new RegionEntity();

            entity.RegionId = request.RegionId;

            var excludedIncludedFields = RepositoryHelper.ConvertStringToExcludedIncludedFields(EntityType, request.Select);
            var prefetchPath           = RepositoryHelper.ConvertStringToPrefetchPath(EntityType, request.Include, request.Select);

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                OnBeforeFetchRegionPkRequest(adapter, request, entity, prefetchPath, excludedIncludedFields);

                var pkPredicate = adapter.CreatePrimaryKeyFilter(entity.Fields.PrimaryKeyFields);
                entity = base.Fetch(adapter, pkPredicate, prefetchPath, excludedIncludedFields, request.RCache);
                if (entity != null)
                {
                    OnAfterFetchRegionPkRequest(adapter, request, entity, prefetchPath, excludedIncludedFields);
                    return(new RegionResponse(entity.ToDto()));
                }
            }
            return(new RegionResponse(null));
        }
        public ProductResponse Fetch(ProductUcProductNameRequest request)
        {
            var entity = new ProductEntity();

            entity.ProductName = request.ProductName;

            var excludedIncludedFields = RepositoryHelper.ConvertStringToExcludedIncludedFields(EntityType, request.Select);
            var prefetchPath           = RepositoryHelper.ConvertStringToPrefetchPath(EntityType, request.Include, request.Select);

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                var ucPredicate = entity.ConstructFilterForUCProductName();
                OnBeforeFetchProductUcProductNameRequest(adapter, request, entity, ucPredicate, prefetchPath, excludedIncludedFields);

                entity = base.Fetch(adapter, ucPredicate, prefetchPath, excludedIncludedFields, request.RCache);
                if (entity != null)
                {
                    OnAfterFetchProductUcProductNameRequest(adapter, request, entity, ucPredicate, prefetchPath, excludedIncludedFields);
                    return(new ProductResponse(entity.ToDto()));
                }
            }
            return(new ProductResponse(null));
        }