.NET Generic + MembershipUserCollection

J

Jeff

ASP.NET 2.0

This is a generic class
List<Contact> contacts = Contact.GetContacts(profile.UserName);
Every Contact object holds info about a UserName from aspnet_Users. So
Contact.GetContacts selects all users in aspnet_Users (well, it don't select
everytime, it mostly uses cache, so it is fast) and create a Contact object
for each user..... - In addition these Contact objects holds info which
isn't available in MembershipUser, so that's why I'm not using
MembershipUser

PROBLEM:
But now I need the MembershipUser object for every Contact object. I need to
access info about if this user is online and which role he belong to etc...
So I'm thinking like these:
foreach (Contact contact in contacts)
{
MembershipUser usr = MembershipUserCollection[contact.UserName];
}
But I'm not sure this will work. Will
MembershipUserCollection[contact.UserName]; return a MembershipUser?

any suggestions?

Jeff
 
M

Mark Rae

But I'm not sure this will work. Will
MembershipUserCollection[contact.UserName]; return a MembershipUser?

Probably, though you might have to explicity cast it i.e.

(MembershipUser)MembershipUserCollection[contact.UserName];
 
J

Jeff

Well, the problem was that I wasn't sure this would work. So I posted this
thread before I tryed the code...

It is solved now
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top