Ejemplo n.º 1
0
        public OrderDetailsExtendedCollectionResponse Fetch(OrderDetailsExtendedQueryCollectionRequest 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 OrderDetailsExtendedTypedView();

            using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter())
            {
                OnBeforeFetchOrderDetailsExtendedQueryCollectionRequest(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);
                OnAfterFetchOrderDetailsExtendedQueryCollectionRequest(adapter, request, typedView, sortExpression, includedFieldNames, predicateBucket,
                                                                       request.PageNumber, request.PageSize, request.Limit, totalItemCount);
            }

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

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

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

            return(response);
        }
Ejemplo n.º 2
0
 partial void OnAfterFetchOrderDetailsExtendedQueryCollectionRequest(IDataAccessAdapter adapter, OrderDetailsExtendedQueryCollectionRequest request, OrderDetailsExtendedTypedView typedView, SortExpression sortExpression, string[] includedFieldNames, IRelationPredicateBucket predicateBucket, int pageNumber, int pageSize, int limit, int totalItemCount);