Following is the code I have in my API classes:
Code:
unityContainer.RegisterType<ISecurityManagementService, SecurityManagementService>(new Interceptor<TransparentProxyInterceptor>(), new InterceptionBehavior<PolicyInjectionBehavior>());
And then there are simple APIs/repositories:
Code:
unityContainer.RegisterType<IUserRepository, UserRepository>();
Service classes are exposed to the client, and so have method attributes to control who can access it and all. Repositories service the requests for data, and in turn use Entity Framework 4.0 as the DAL.
I want to implement caching at the repository level, so that repeated read requests for the data needn't hit the database every time. For e.g. the UserRepository class has a method as follows:
Code:
public IList<User> GetAll()
{
...
}
Usually it would fetch the list from the database every time. I want to use caching here to ensure it doesn't go to the database every time. However I notice that the repository objects are not persistent. How do I make them persistent? Alternatively how do I implement caching?
.
EDIT
Found the answer: Lifetimemanagers. Aarghhh!!