views:

337

answers:

2

Hi, I'm using ASP.NET MVC 1 and I have added a custom Profile class using the WebProfile Builder VS add-in (found here: http://code.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=980).

On one of my forms I want a drop-down list of all users who share a specific profile value in common.

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

Membership.GetAllUsers()

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

Am I approaching this in the right way? I have used membership roles to define which users are administrators etc, but profiles seems like the right place to group users.

Any pointers both in specifics of how to access the user list but also comments on whether am I pursuing the right avenue here would be greatly appreciated.

Many thanks, Sam

A: 

I have the same problem. My guess is that you have to retrieve ALL the users, loop through ALL of them, and then compare your profile property to the value of your choice. I hope I'm wrong though. Bump.

d00d
you are not mistaken.
Sky Sanders
+1  A: 

There is no query API for Profile, but this may give you some guidance:

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();
Sky Sanders