Skip to content

Instantly share code, notes, and snippets.

@danstuken
Created October 11, 2011 13:14
Show Gist options
  • Save danstuken/1278039 to your computer and use it in GitHub Desktop.
Save danstuken/1278039 to your computer and use it in GitHub Desktop.
Possible caching data reader.
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