I want to cache a data collection in asp.net mvc and filter this collection without to changed the cached collection.
Is it possible to do this?
Because for now, when I get my cached collection I get a reference to it and filter data of this collection change the cached collection.
Does anyone know?
I finally resolve my problem by creating a Clone() method in each of my objects and call Clone () method on my main object just after I retrieved it from cache.
My main object is of type account which contain himself list of domains, which contain list of product, etc…
Here is the Clone method in the Account object :
Like you can see I use MemberwiseClone() to copy simple property and then I call Clone again on all complex objects. Clone which is a custom method I created in all of my complex objects.
And now it work fine…