asp.net mvc 4 - Entity Framework only allow one query -
i making call sql database via entity framework, call takes 2 mins execute. want make sure call occurs once. once call made, place results in cache. notice if multiple users on site, can more 2 mins till data returned, whats best way approach this? should use mutex? or entity framework (version 4) have functionality built in handle type of situation. using mvc 4. thank you!
public ienumerable<adlisting> allactiveads() { try { if (pullcache(constants.cachekeys.allactiveads) == null) { using (var db = new myentities()) { db.commandtimeout = 300; list<adlisting> results = (from in db.adlistings .include("adphotos") .include("tblocation") !a.deleted select a).tolist(); pushcache(results, constants.cachekeys.allactiveads); } } return (list<adlisting>) pullcache(constants.cachekeys.allactiveads); } catch (exception ex) { handleexception(ex); return null; } }
Comments
Post a Comment