ASP.NET MVC Get a list of users with specific profile properties.

I use ASP.NET MVC 1 and I added my own profile class using the WebProfile Builder VS add-on (found here: http://code.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=980 ).

In one of my forms, I want a drop-down list of all users who share a specific profile value.

I see that I can get a list of all users using:

Membership.GetAllUsers()

However, I do not see how to get all users who have a specific profile value, which in my case is CellId.

Am I approaching this correctly? I used membership roles to determine which users are administrators, etc., but profiles look like a good place to group users.

Any pointers are welcome, especially in terms of how to access the list of users, and in the comments about whether I will pursue the right path here.

Thanks a lot Sam

+5
source share
2 answers

There is no request API for the profile, but this may give you some suggestions:

var usersWithNonZeroCounter = Membership.GetAllUsers().Cast<MembershipUser>()
    .Where(user => true /*insert your user criteria here*/)
    .Select(user => ProfileBase.Create(user.UserName, true))
    .Where(profile => ((int)profile["counter"]) > 0 /*insert your profile criteria here*/)
    .ToList();
+3
source

If you need only one comparison, you can use the following statement:

return Membership.GetAllUsers().Cast<MembershipUser>()
        .Where(user => ((int)ProfileBase.Create(user.UserName, true)["Owner"]) == _ownerid);

, let .

+1

All Articles