rockinthesixstring - yes, you can add the http cache to this layer using an anonymous function to either pull it out of the repo or extract it from the cache. basically you would do it in the following lines (this is from an application I'm working on now that uses subsonic, but the premise that you are behind it is identical.
[edit] in the controller you would name it like this (the _repository controller is set as:
readonly IRepository<Booking> _repository;
in the example):
[Authorize] [AcceptVerbs(HttpVerbs.Post)] public ContentResult ListBookings(int shareholderid) { Expression<Func<Booking, bool>> exprTree = x => x.FundShareholderEntity.ShareholderID == shareholderid; var bookings = _repository.Find(exprTree).OrderByDescending(x => x.BookingDetailEntity.ActualDateFrom).OrderBy(x => x.BookingTypeID); return Content(this.RenderPartialToString("BookingListNoPaging", bookings)); }
In the above example, Cache (i.e. Cache.Get ()) is a class that is more convenient for the httpcontext cache.
hope this helps ...
jim
[edit] - added cache interface to add to the "discussion" :)
public interface ISessionCache { T Get<T>(string key); T Get<T>(string key, Func<T> getUncachedItem, int cacheDuration); void Insert(string key, object obj, int cacheDuration, CacheDependency arg0, TimeSpan arg2); void Remove(string key); object this[string key] { get; }
in the injection class will be used line by line:
public class FakeCache : ISessionCache {... all inteface members implemented here etc..}
or for httpcache:
public class HttpContextCache : ISessionCache {... all inteface members implemented here etc..}
etc. etc. welcome again - jim
source share