| Author |
.NET Generic + MembershipUserCollection
|
|
|
| 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
| |
|
| Okay I assume it works....
"Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in message
news:O3KtHF4cHHA.4872@TK2MSFTNGP03.phx.gbl...
> 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
>
| |
| Mark Rae 2007-03-31, 8:06 am |
| "Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in message
news:O3KtHF4cHHA.4872@TK2MSFTNGP03.phx.gbl...
> 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];
| |
| Mark Rae 2007-03-31, 7:05 pm |
| "Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in message
news:O6BdJk4cHHA.4888@TK2MSFTNGP06.phx.gbl...
> Okay I assume it works....
What happened when you tried...?
| |
|
| I get a MembershipUser object. I didn't do any casting.
"Mark Rae" <mark@markNOSPAMrae.com> wrote in message
news:uCOR3z5cHHA.4516@TK2MSFTNGP04.phx.gbl...
> "Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in message
> news:O6BdJk4cHHA.4888@TK2MSFTNGP06.phx.gbl...
>
>
> What happened when you tried...?
>
| |
| Mark Rae 2007-03-31, 7:05 pm |
| "Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in message
news:ufoY1P6cHHA.4984@TK2MSFTNGP05.phx.gbl...
>I get a MembershipUser object. I didn't do any casting.
Er, OK... so, what was the problem, then...?
| |
|
| 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
"Mark Rae" <mark@markNOSPAMrae.com> wrote in message
news:OvkF$I7cHHA.984@TK2MSFTNGP04.phx.gbl...
> "Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in message
> news:ufoY1P6cHHA.4984@TK2MSFTNGP05.phx.gbl...
>
>
> Er, OK... so, what was the problem, then...?
>
|
|
|
|