LINQ to SQL repository - caching data

LINQ to SQL repository - caching data

I have built my first MVC solution and used the repository pattern for retrieving/inserting/updating my database.

I am now in the process of refactoring and I've noticed that a lot of (in fact all) the methods within my repository are hitting the database everytime. This seems overkill and what I'd ideally like is to do is 'cache' the main data object e.g. 'GetAllAdverts' from the database and to then query against this cached object for things like 'FindAdvert(id), AddAdvert(), DeleteAdvert() etc..'

I'd also need to consider updating/deleting/adding records to this cache object and the database.

What is the best apporoach for something like this?

My knowledge of this type of things is minimal and really looking for advice/guidance/tutorial to point me in the right direction.

Thanks in advance.



Is ADO.NET Entity Framework (with ASP.NET MVC v2) a viable option when writing custom and contantly updated websites?
This just hit my radar, and I assume you have already solved the issue by now. How to disable VS compile warning “class or css class is not defined”But if not, I would look into Pre-Compiled LINQ Queries. patterns to use when building complex web UISomething like this:. Validation not firing even when my form is obviously invalid
        private static Func<SomeDataContext, int, PersonDto> _receive PersonByIdQuery =        CompiledQuery.Compile<SomeDataContext, int, PersonDto>(            (dataContext, personId) =>                dataContext.PersonDtos.where(c => c.PersonId == personId).FirstOrDefault()                ); 
Put any thing like this inside of your datacontext, then add an internal method in there to call it call it. mvc datannotation password validateYour retriever/saver will then call the internal method. ASP.NET MVC - How controls retain their stateDoes this make sense? I must post more code if necessary... JavaScript url auto-resolution in Asp.Net MVC Best of luck,. Justin.

62 out of 100 based on 57 user ratings 772 reviews