persisting customer session

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 лет назад
Hello Everybody

I have wanted to ask how can i make a customer object persist through a session and not per http request.

As i have noticed, when i turn to another page, the workContext loads the customer from scratch instead of loading it from cache.

Thnaks alot.
12 лет назад
Entity Framework does not support caching between requests.
12 лет назад
Maybe i would state my original problem:

i need to have a dictionary of customers. the key is customerId and the value is some metric.
Since i could not implemented the dictionary in EF. i have done it manually- initializing the dictionary every time
there was a request for a customer(workContext.CurrentCustomer for example).

The problem is that every browse in the site he needed to build the customers dictionary, therefore expansive performance wise. this is pointless since the customer have not really changed.

Is there a way to tell the context object to save the customer in a session, or should i implement it my self via the http session? if so i would be happy to get some recommendations.

p.s- i saw some interface -IStatefulStorage. is this helpful in any way?

Thank you very much.
12 лет назад
Yes, IStatefulStorage can be used to store values between requests during session.

But I wouldn't recommend to cache changeable entities between requests. As I've written above Entity Framework does not support caching between requests. It can cause some issues because DbContext is created for each new request and you'll have to manually detach/attach cached entities each time you want to update them.

P.S. There's a forum topic about it describing this issue (I can't find it now).
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.