Is this possible to populate some constant small tables as cache for DataContext without using database?
For example, I have 10 Roles rows, and wonna quick (without database hit) access to them when doing big select?
Is this possible to populate some constant small tables as cache for DataContext without using database?
For example, I have 10 Roles rows, and wonna quick (without database hit) access to them when doing big select?
If you cache the result of the first database hit subsequent hits will be prevented and will be called from cache.
var rolesList = (List<Role>)Cache["cachedroles"];
if (rolesList == null)
{
using (var tDC= new theDataContext())
{
rolesList = siteroles.allrolesItems(tDC).OrderBy(c => c.listOrder).ToList();
Cache.Insert("cachedroles", rolesList);
}
}