views:

42

answers:

1

Anyone know an equiv?

Currently I'm doing..

Dim myUsers As New MembershipUserCollection
Dim myUser As MembershipUser
Dim RoleUsers() As String
RoleUsers = Roles.GetUsersInRole("User")

For Each x As String In RoleUsers
    Dim roleUser As MembershipUser
    roleUser = Membership.GetUser(x)
    If Not roleUser Is Nothing Then
        myUsers.Add(Membership.GetUser(x))
    End If
Next

Just wondering if there's something like..

If MembershipUser.TryParse(Membership.GetUser(x),myUser) Then
    myUsers.Add(myUser)
End If

VB or C# works.

A: 

The problem is no method (neither in Roles nor in MembershipUser ) that deals with class instead of string name. So may be there is a sense in direct SQL to database (in case of SqlMembershipProvider usage).

Using LINQ makes your code more elegant but doesn't resolve performance issue.

Dewfy