I have a list of all memberships:
Dim allUsers = Membership.GetAllUsers().Cast(Of MembershipUser).ToList
Despite my searches, I have been unable to figure out how to loop through this to do something like the following. I want to loop through and retrieve a record, if the record contains a certain value, add the user to a new collection.
for each allusers as user
' get user profile
' if user profile has a certain value, add it to another collection
end for each
Then, once the new collection is full, output that collection to my view.
Does that make sense? How can I do this? Thank you.
Try this:
Public Function GetUsers() As IEnumerable(Of MembershipUser)
Dim newListOfUsers = New List(Of MembershipUser)()
Dim users As MembershipUserCollection = Membership.GetAllUsers()
For Each user As MembershipUser In users
If user.Comment = "A Leather Glove" Then
newListOfUsers.Add(user)
End If
Next
Return newListOfUsers
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With