Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Harshit 64 posts 226 karma points
    Mar 07, 2016 @ 08:30
    Harshit
    0

    UserService GetAll method parameters

    Hi,

    I am trying to fetch all the users using UserService however I am little bit confused about the GetAll parameters as below:

     IEnumerable<T> GetAll(int pageIndex, int pageSize, out int totalRecords);
    

    any idea about pageIndex, pageSize, totalRecords?from where we can identify these values?

    Regards, Harsh

  • Kevin Jump 2342 posts 14869 karma points MVP 8x c-trib
    Mar 07, 2016 @ 09:18
    Kevin Jump
    1

    Hi

    I think the GetAll call has been written to deal with paging in case you have loads of users.

    to get all users

    int total = 0;    
    var users = _userService.GetAll(0, int.MaxValue, out total);
    

    users will be the users total will be how many users you have.

    this will do, but the call is designed so you can loop through so if you have lots (like 1000's of users). something like*

    int pageSize = 1000;
    int total = 0;
    int index = 0;
    
    do {
      var someUsers = _userService.GetAll(index, pageSize, total)
    
     //   ... you will have users in 1000's
    
      index += total; 
    } while ( total == pageSize ) 
    

    *i would check this, just typed it into the comment, it's never actually been compiled

Please Sign in or register to post replies

Write your reply to:

Draft