J
Jeff
Hey
ASP.NET 2.0
I'm developing a web page displaying a list of messages, the code
(GetInboxMessages) below is the method which gives the a list of messages to
this web page's reapeat control
a message is text typed in by a user
a message contain these fields: Id, dataCreated, sender, receiver, body
sender and receiver is the foreign key to the users, sender is the person
sent the message, and receiver is the receiver of the message
In the repeat control the user should be able to click on a message and then
send a respond to the message clicked. When clicking on a message I want a
new web page to open displaying the message clicked and an area for the user
to type in a respond!
the PROBLEM is that I don't know how to get this specific message, I mean is
that in the first page (see the code below - GetInboxMessages) all messages
are saved in a cache (or is it?) and then it whould be needless to access
the specific message from the database. So how can I get the message from
the cache?
The only solution to this I know about is this:
List<Message> list = GetInboxMessages(string user)
and iterate this list of message, using a foreach statement. test every
message until I find the message contain the Id of the message I'm looking
for.. But isn't there a better way in .NET 2.0 Generic?
public static List<Message> GetInboxMessages(string user)
{
List<Message> messages = null;
string key = "InboxMessages";
if (BaseNetwork.Settings.EnableCaching && BizObject.Cache[key] != null)
{
messages = (List<Message>)BizObject.Cache[key];
}
else
{
List<MessageDetails> recordset =
SiteProvider.Network.GetInboxMessages(user);
messages = GetMessageListFromMessageDetailsList(recordset);
BaseNetwork.CacheData(key, messages);
}
return messages;
}
Any suggestions?
Best Regards
Jeff
ASP.NET 2.0
I'm developing a web page displaying a list of messages, the code
(GetInboxMessages) below is the method which gives the a list of messages to
this web page's reapeat control
a message is text typed in by a user
a message contain these fields: Id, dataCreated, sender, receiver, body
sender and receiver is the foreign key to the users, sender is the person
sent the message, and receiver is the receiver of the message
In the repeat control the user should be able to click on a message and then
send a respond to the message clicked. When clicking on a message I want a
new web page to open displaying the message clicked and an area for the user
to type in a respond!
the PROBLEM is that I don't know how to get this specific message, I mean is
that in the first page (see the code below - GetInboxMessages) all messages
are saved in a cache (or is it?) and then it whould be needless to access
the specific message from the database. So how can I get the message from
the cache?
The only solution to this I know about is this:
List<Message> list = GetInboxMessages(string user)
and iterate this list of message, using a foreach statement. test every
message until I find the message contain the Id of the message I'm looking
for.. But isn't there a better way in .NET 2.0 Generic?
public static List<Message> GetInboxMessages(string user)
{
List<Message> messages = null;
string key = "InboxMessages";
if (BaseNetwork.Settings.EnableCaching && BizObject.Cache[key] != null)
{
messages = (List<Message>)BizObject.Cache[key];
}
else
{
List<MessageDetails> recordset =
SiteProvider.Network.GetInboxMessages(user);
messages = GetMessageListFromMessageDetailsList(recordset);
BaseNetwork.CacheData(key, messages);
}
return messages;
}
Any suggestions?
Best Regards
Jeff