question

peterliles-4155 avatar image
0 Votes"
peterliles-4155 asked LanHuang-MSFT commented

Efficient paging with MembershipUser object and pageddatasource

I am trying to implement efficient paging using LINQ like:

Dim numberOfObjectsPerPage As Integer = ddlPageSize.SelectedValue
Dim queryResultPage = MembershipUserODS.GetMembersCompose(sortexpression, usernametofind, roleid, UsernameToMatch, Me.PageIndex, totalRecords)
queryResultPage.Skip(numberOfObjectsPerPage * Me.PageIndex).Take(numberOfObjectsPerPage)


         pagingSource.DataSource = queryResultPage


The queryResultPage variable returns the total row count and not the subset page size value as expected?

dotnet-aspnet-webpages
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @peterliles-4155,
Have you not implemented the paging function?
And what is the function of the GetMembersCompose method?
If it is convenient to provide more code or test data, so that I can better help you solve the problem.
Best regards,
Lan Huang

0 Votes 0 ·

I have connected up to this function and tested to see if it returns subset of results 5 but it still returns full count of membershiplist 10

Private Shared memberList As List(Of MembershipUserWrapper)

Dim muc As MembershipUserCollection = Membership.GetAllUsers()
If muc IsNot Nothing Then


                 For Each mu As MembershipUser In muc

                 
                         Dim md As MembershipUserWrapper = New MembershipUserWrapper(mu)
                         memberList.Add(md)
                  
                 Next
             End If

Return memberList.Skip(startIndex).Take(maxRows).ToList()



0 Votes 0 ·

1 Answer

LanHuang-MSFT avatar image
0 Votes"
LanHuang-MSFT answered LanHuang-MSFT commented

Hi @peterliles-4155,

Return memberList.Skip(startIndex).Take(maxRows).ToList()

Regarding Skip(1).Take(5), skip the first data and take 5 data from the second.
What are the values of startIndex and maxRows?
Maybe you can imitate the following code:
132401-1.png

If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best regards,
Lan Huang


1.png (4.4 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The strange thing happens is that the generic membershiplist object set in your code does not affect the data return until after when the calling method return data is then processed further with SKIP and TAKE as shown above ??

0 Votes 0 ·
LanHuang-MSFT avatar image LanHuang-MSFT peterliles-4155 ·

Hi @peterliles-4155,

Return memberList.Skip(startIndex).Take(maxRows).ToList()

What are the values of startIndex and maxRows?
Maybe you can provide more detailed code to help you.

Best regards,
Lan Huang

0 Votes 0 ·