views:

265

answers:

1

ASP.NET 2.0 membership, roles, and profiles is the cat's meow. The API for roles supports handy methods like GetAllUsersInRole("MyNewsletterSubscriber"), which will return a collection of people in the "MyNewsletterSubscriber" role.

I am wondering what the best way to return a collection of people with custom ASP.NET Profile properties might be. So for example, I might create one custom profile property called IsNewsletter1SubscriptionUserSelectionTextOnly and another custom profile property called IsNewsletter1UserSelectionMobileOptimized.

How then, can I most efficiently query for something akin to GetAllUsersWithCustomProfileProperty("IsNewsletter1SubscriptionUserSelectionTextOnly", true);

For the use I'm envisioning, the API around Profiles seems underdeveloped -- I think Scott Guthrie mentioned some forthcoming work on it at his talk at Tech Ed 2006, but I don't know what's been done.

It may also be that I'm trying to use Profiles inappropriately, and it would be better to store all of this junk as straight roles. Don't know. I like the idea of using Roles or Profiles for list management, but I don't know the cleanest way to manage it.

Thoughts, idea, answers? Thanks...

A: 

Well, querying on profiles--at least with the default SQL implementation--is scary because you are really querying on a binary serialized field, so every query needs to load every row in the database, deserialize said binary and then check the answer. So don't cheat and do it with LINQ to Objects or something, your DBA will shoot you.

Anyhow, my rule is as soon as you want to query on profile, you had better implement a custom provider that is queryable in a normal fashion. Usually this ends up being part of the domain model.

Wyatt Barnett