473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

.NET Generic + MembershipUserCollection

ASP.NET 2.0

This is a generic class
List<Contactcontacts = 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
Mar 31 '07 #1
6 2031
Okay I assume it works....

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:O3**************@TK2MSFTNGP03.phx.gbl...
ASP.NET 2.0

This is a generic class
List<Contactcontacts = 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

Mar 31 '07 #2
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:O3**************@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];
Mar 31 '07 #3
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:O6**************@TK2MSFTNGP06.phx.gbl...
Okay I assume it works....
What happened when you tried...?
Mar 31 '07 #4
I get a MembershipUser object. I didn't do any casting.

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:uC**************@TK2MSFTNGP04.phx.gbl...
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:O6**************@TK2MSFTNGP06.phx.gbl...
>Okay I assume it works....

What happened when you tried...?

Mar 31 '07 #5
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:uf**************@TK2MSFTNGP05.phx.gbl...
>I get a MembershipUser object. I didn't do any casting.
Er, OK... so, what was the problem, then...?
Mar 31 '07 #6
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" <ma**@markNOSPAMrae.comwrote in message
news:Ov*************@TK2MSFTNGP04.phx.gbl...
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:uf**************@TK2MSFTNGP05.phx.gbl...
>>I get a MembershipUser object. I didn't do any casting.

Er, OK... so, what was the problem, then...?

Apr 1 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Andreas Huber | last post by:
What follows is a discussion of my experience with .NET generics & the ..NET framework (as implemented in the Visual Studio 2005 Beta 1), which leads to questions as to why certain things are the...
1
by: xenophon | last post by:
I want to bind a DropDownList to the names in a MembershipUserCollection. How can I do that, sorting the names alphabetically? Using ASP.NET 2.0. Thanks.
2
by: Justin Drerup | last post by:
I'm tryng to return a custom object that contains a collection of MembershipUsers through a web service however I receive the following error when trying to return the object through a web method:...
9
by: mps | last post by:
I want to define a class that has a generic parameter that is itself a generic class. For example, if I have a generic IQueue<Tinterface, and class A wants to make use of a generic class that...
13
by: rkausch | last post by:
Hello everyone, I'm writing because I'm frustrated with the implementation of C#'s generics, and need a workaround. I come from a Java background, and am currently writing a portion of an...
7
by: Dave | last post by:
I've got these declarations: public delegate void FormDisplayResultsDelegate<Type>(Type displayResultsValue); public FormDisplayResultsDelegate<stringdisplayMsgDelegate; instantiation:...
26
by: raylopez99 | last post by:
Here is a good example that shows generic delegate types. Read this through and you'll have an excellent understanding of how to use these types. You might say that the combination of the generic...
0
by: Bogdan | last post by:
Hi, Can a GridView bound to a MembershipUserCollection sort its content? For example, can the GridView"s rows be sorted by UserName? If yes, could someone point me in the right direction? ...
2
by: SimonDotException | last post by:
I am trying to use reflection in a property of a base type to inspect the properties of an instance of a type which is derived from that base type, when the properties can themselves be instances of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.