asp.net mvc - prepopulate MVC Models with IOC - an alternative to caching? -
I am considering strategies for a simple minded CMS implementation for an ASP.NET MVC site. The simple-minded part is that I have consolidated the values used in many partial ideas, which are all user controls that share the same CSS layout. That's why I am populating custom values from the database into even partial visuals where I can sometimes modify them using the CRUD.
Not so easy, a functional and logical abstraction of a standard UI element is a SQL table row but it is putting aside ...
I know that I have some super Using models, I am going to use each page for pre-configured models for partial views. But if they are pre-configured and pre-loaded then where are they kept?
The part from which I feel that I'm a bit crazy to go this way, it's essentially the time to load the static data but again, SharePoint!
Why (I think) why not load it all in application_start? why not? I answer! Then I can use IOC for something that Google does not even link to a smart person for good information, which has ever assumed that it could be a sensible idea.
So anyone has a better idea to be popular, apart from putting a repository call in the constructor, using a IoC container, a model from the database?
And then, does anyone think that making these static data models accessible to controllers in the IOC container is a dumb idea?
Thanks,
S. Macino
Keep your luggage unobtrusive as possible, following several concrete principles . For semi-static data, first create a repository that loads this data. This will load the data for every request. It works, but probably does not perform well, but now you need to implement.
The next thing you can do is decorate the repository with the caching repository first. This caching repository will only be read from the repository once decorated, and then keep the data in the memory.
In this way you respect the separation of concerns.
If you scope the caching repository instances to be single, it will survive until the application is recycled, keeping the cached data in memory effectively.
Comments
Post a Comment