none
WCF custom pagination cause service fault RRS feed

  • Question

  • I have in memory Dictionary, I want to apply pagination on <g class="gr_ gr_14 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="14" id="14">it </g><g class="gr_ gr_12 gr-alert gr_gramm gr_inline_cards gr_run_anim Style replaceWithoutSep" data-gr-id="12" id="12"><g class="gr_ gr_14 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" data-gr-id="14" id="14">,</g>So</g> I used this custom class and interface

    public interface IPagedList<T> : IList<T>
    {
        int PageCount { get; }
        int TotalItemCount { get; }
        int PageIndex { get; }
        int PageNumber { get; }
        int PageSize { get; }
        bool HasPreviousPage { get; }
        bool HasNextPage { get; }
        bool IsFirstPage { get; }
        bool IsLastPage { get; }
    }
    public class PagedList<T> : List<T>, IPagedList<T>
    {
        public PagedList(IEnumerable<T> source, int index, int pageSize, int? totalCount = null)
            : this(source.AsQueryable(), index, pageSize, totalCount)
        {
        }
    
        public PagedList(IQueryable<T> source, int index, int pageSize, int? totalCount = null)
        {
            if (index < 0)
                throw new ArgumentOutOfRangeException("index", "Value can not be below 0.");
            if (pageSize < 1)
                throw new ArgumentOutOfRangeException("pageSize", "Value can not be less than 1.");
    
            if (source == null)
                source = new List<T>().AsQueryable();
    
            var realTotalCount = source.Count();
    
            PageSize = pageSize;
            PageIndex = index;
            TotalItemCount = totalCount.HasValue ? totalCount.Value : realTotalCount;
            PageCount = TotalItemCount > 0 ? (int) Math.Ceiling(TotalItemCount / (double) PageSize) : 0;
    
            HasPreviousPage = PageIndex > 0;
            HasNextPage = PageIndex < PageCount - 1;
            IsFirstPage = PageIndex <= 0;
            IsLastPage = PageIndex >= PageCount - 1;
    
            if (TotalItemCount <= 0)
                return;
    
            var realTotalPages = (int) Math.Ceiling(realTotalCount / (double) PageSize);
    
            if (realTotalCount < TotalItemCount && realTotalPages <= PageIndex)
                AddRange(source.Skip((realTotalPages - 1) * PageSize).Take(PageSize));
            else
                AddRange(source.Skip(PageIndex * PageSize).Take(PageSize));
        }
    
        #region IPagedList Members
    
    
        public int PageCount { get; }
    
    
        public int TotalItemCount { get; }
    
    
        public int PageIndex { get; }
    
    
        public int PageNumber => PageIndex + 1;
    
    
        public int PageSize { get; }
    
    
        public bool HasPreviousPage { get; }
    
    
        public bool HasNextPage { get; }
    
    
        public bool IsFirstPage { get; }
    
    
        public bool IsLastPage { get; }
    
        #endregion
    }

    and  <g class="gr_ gr_24 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" data-gr-id="24" id="24">my</g> operationContract do the following

    [OperationContract]
            PagedList<AttributeBinding> RetrieveDetailsAllBindings(int currentPage, int itemsPerPage);

    I tried to solve that by tag  <g class="gr_ gr_5 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="5" id="5">pagedlist</g> with <g class="gr_ gr_15 gr-alert gr_gramm gr_hide gr_inline_cards gr_run_anim Style multiReplace replaceWithoutSep replaceWithoutSep" data-gr-id="15" id="15">CollectionDataContract </g><g class="gr_ gr_13 gr-alert gr_gramm gr_inline_cards gr_run_anim Style replaceWithoutSep" data-gr-id="13" id="13"><g class="gr_ gr_15 gr-alert gr_gramm gr_hide gr_inline_cards gr_disable_anim_appear Style multiReplace replaceWithoutSep replaceWithoutSep" data-gr-id="15" id="15">,</g>but</g> same fault exception in client side, I also followed this approach CollectionDataContract but without hope, any suggestion on how to make this method reach the client without <g class="gr_ gr_6 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="6" id="6">faultexception</g> <g class="gr_ gr_7 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="7" id="7">aslo</g> I tried to decorate  with  <g class="gr_ gr_8 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="8" id="8">knowntype</g> list  which is a custom class with  <g class="gr_ gr_9 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="9" id="9">datacontract</g> but it didn't work




    • Edited by aabdellatif Wednesday, November 28, 2018 6:40 AM
    Tuesday, November 27, 2018 4:00 PM

All replies

  • I have in memory Dictionary, I want to apply pagination on <g class="gr_ gr_5 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="5" id="5">it ,</g> So I used this custom class and interface

    public interface IPagedList<T> : IList<T>
    {
        int PageCount { get; }
        int TotalItemCount { get; }
        int PageIndex { get; }
        int PageNumber { get; }
        int PageSize { get; }
        bool HasPreviousPage { get; }
        bool HasNextPage { get; }
        bool IsFirstPage { get; }
        bool IsLastPage { get; }
    }
    public class PagedList<T> : List<T>, IPagedList<T>
    {
        public PagedList(IEnumerable<T> source, int index, int pageSize, int? totalCount = null)
            : this(source.AsQueryable(), index, pageSize, totalCount)
        {
        }
    
        public PagedList(IQueryable<T> source, int index, int pageSize, int? totalCount = null)
        {
            if (index < 0)
                throw new ArgumentOutOfRangeException("index", "Value can not be below 0.");
            if (pageSize < 1)
                throw new ArgumentOutOfRangeException("pageSize", "Value can not be less than 1.");
    
            if (source == null)
                source = new List<T>().AsQueryable();
    
            var realTotalCount = source.Count();
    
            PageSize = pageSize;
            PageIndex = index;
            TotalItemCount = totalCount.HasValue ? totalCount.Value : realTotalCount;
            PageCount = TotalItemCount > 0 ? (int) Math.Ceiling(TotalItemCount / (double) PageSize) : 0;
    
            HasPreviousPage = PageIndex > 0;
            HasNextPage = PageIndex < PageCount - 1;
            IsFirstPage = PageIndex <= 0;
            IsLastPage = PageIndex >= PageCount - 1;
    
            if (TotalItemCount <= 0)
                return;
    
            var realTotalPages = (int) Math.Ceiling(realTotalCount / (double) PageSize);
    
            if (realTotalCount < TotalItemCount && realTotalPages <= PageIndex)
                AddRange(source.Skip((realTotalPages - 1) * PageSize).Take(PageSize));
            else
                AddRange(source.Skip(PageIndex * PageSize).Take(PageSize));
        }
    
        #region IPagedList Members
    
    
        public int PageCount { get; }
    
    
        public int TotalItemCount { get; }
    
    
        public int PageIndex { get; }
    
    
        public int PageNumber => PageIndex + 1;
    
    
        public int PageSize { get; }
    
    
        public bool HasPreviousPage { get; }
    
    
        public bool HasNextPage { get; }
    
    
        public bool IsFirstPage { get; }
    
    
        public bool IsLastPage { get; }
    
        #endregion
    }

    and <g class="gr_ gr_77 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" data-gr-id="77" id="77">my</g> operationContract do the following

    [OperationContract]
            PagedList<AttributeBinding> RetrieveDetailsAllBindings(int currentPage, int itemsPerPage);

    I tried to solve that by tag  <g class="gr_ gr_112 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="112" id="112">pagedlist</g>  with <g class="gr_ gr_27 gr-alert gr_gramm gr_hide gr_inline_cards gr_run_anim Style multiReplace replaceWithoutSep" data-gr-id="27" id="27">CollectionDataContract ,</g> but sam fault exception in client side, I also followed this approach CollectionDataContract but without hope, any suggestion on how to make this method reach the client without <g class="gr_ gr_18 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="18" id="18">faultexception</g> <g class="gr_ gr_19 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="19" id="19">aslo</g>  I tried to decorate  <g class="gr_ gr_20 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="20" id="20">pagedlist</g> with  <g class="gr_ gr_21 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="21" id="21">knowntype</g> list  which is a custom class with  <g class="gr_ gr_33 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="33" id="33">datacontract</g> but it didn't work



    And someone is suppose to read this? Whatever browser you are using, you should stop using it when making posts. 
    • Edited by DA924x Wednesday, November 28, 2018 6:21 AM
    Wednesday, November 28, 2018 6:20 AM
  • and do u suppose that I noticed <g class="gr_ gr_20 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="20" id="20">this ?</g> 
    Wednesday, November 28, 2018 6:39 AM
  • and do u suppose that I noticed <g class="gr_ gr_20 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="20" id="20">this ?</g> 

    Can you stop posting the gibberish? Can you turn off whatever junk you have that is making the browser do it or install another browser that doesn't do it?  Are you this hard- headed?

    Do you see the Edit link at the bottom of your post? Edit the post man and clean the thing up.


    • Edited by DA924x Wednesday, November 28, 2018 9:46 AM
    Wednesday, November 28, 2018 9:40 AM