Beispiel #1
0
        public SummaryOfSalesByQuarterCollectionResponse Fetch(SummaryOfSalesByQuarterQueryCollectionRequest request)
        {
            base.FixupLimitAndPagingOnRequest(request);

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

            var typedView = new SummaryOfSalesByQuarterTypedView();

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                OnBeforeFetchSummaryOfSalesByQuarterQueryCollectionRequest(adapter, request, sortExpression, includedFieldNames, predicateBucket,
                                                                           request.PageNumber, request.PageSize, request.Limit);
                totalItemCount = (int)adapter.GetDbCount(typedView.GetFieldsInfo(), predicateBucket, null, false);
                adapter.FetchTypedView(typedView.GetFieldsInfo(), typedView, predicateBucket, request.Limit, sortExpression, true, null, request.PageNumber, request.PageSize);
                OnAfterFetchSummaryOfSalesByQuarterQueryCollectionRequest(adapter, request, typedView, sortExpression, includedFieldNames, predicateBucket,
                                                                          request.PageNumber, request.PageSize, request.Limit, totalItemCount);
            }

            var dtos       = new SummaryOfSalesByQuarterCollection();
            var enumerator = typedView.GetEnumerator();

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

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

            return(response);
        }
Beispiel #2
0
 partial void OnAfterFetchSummaryOfSalesByQuarterQueryCollectionRequest(IDataAccessAdapter adapter, SummaryOfSalesByQuarterQueryCollectionRequest request, SummaryOfSalesByQuarterTypedView typedView, SortExpression sortExpression, string[] includedFieldNames, IRelationPredicateBucket predicateBucket, int pageNumber, int pageSize, int limit, int totalItemCount);