public InvoicesCollectionResponse Fetch(InvoicesQueryCollectionRequest 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 InvoicesTypedView(); using (var adapter = DataAccessAdapterFactory.NewDataAccessAdapter()) { OnBeforeFetchInvoicesQueryCollectionRequest(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); OnAfterFetchInvoicesQueryCollectionRequest(adapter, request, typedView, sortExpression, includedFieldNames, predicateBucket, request.PageNumber, request.PageSize, request.Limit, totalItemCount); } var dtos = new InvoicesCollection(); var enumerator = typedView.GetEnumerator(); while (enumerator.MoveNext()) { dtos.Add(Map(enumerator.Current, includedFieldNames)); } var response = new InvoicesCollectionResponse(dtos, request.PageNumber, request.PageSize, totalItemCount); return(response); }
/// <summary>Queries 'Invoices' typed view records using sorting, filtering, paging and more.</summary> public InvoicesCollectionResponse Get(InvoicesQueryCollectionRequest request) { OnBeforeGetInvoicesQueryCollectionRequest(request); var output = Repository.Fetch(request); OnAfterGetInvoicesQueryCollectionRequest(request, output); return(output); }
partial void OnAfterGetInvoicesQueryCollectionRequest(InvoicesQueryCollectionRequest request, InvoicesCollectionResponse response);
partial void OnBeforeGetInvoicesQueryCollectionRequest(InvoicesQueryCollectionRequest request);
partial void OnAfterFetchInvoicesQueryCollectionRequest(IDataAccessAdapter adapter, InvoicesQueryCollectionRequest request, InvoicesTypedView typedView, SortExpression sortExpression, string[] includedFieldNames, IRelationPredicateBucket predicateBucket, int pageNumber, int pageSize, int limit, int totalItemCount);
partial void OnBeforeFetchInvoicesQueryCollectionRequest(IDataAccessAdapter adapter, InvoicesQueryCollectionRequest request, SortExpression sortExpression, string[] includedFieldNames, IRelationPredicateBucket predicateBucket, int pageNumber, int pageSize, int limit);