Created
October 11, 2011 13:14
-
-
Save danstuken/1278039 to your computer and use it in GitHub Desktop.
Possible caching data reader.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static SomeEntity Get(string someEntityIdentifier) | |
{ | |
return Cache.Get(string.Format("MyCacheKey_{0}", someEntityIdentifier), CacheFrequency.Daily, () => | |
{ | |
Entity result = null; | |
DataManager.ReadFromStoredProcedure("some_entity_fetching_stored_proc", new Dictionary<string, object> | |
{ | |
{"@id", someEntityIdentifier }, | |
}, reader => | |
{ | |
while (reader.Read() && result == null) | |
{ | |
//do something with the record here | |
} | |
}); | |
return result; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment