Thanks for the quick response Mike.
I think I can certainly use your suggestion for some of the lookups I'm using.
To complicate matters a little further I now realise I don't wan't to cache the whole collection - only parts of it, and just to retrieve these parts from the cache when available.
At the moment I've come up with the following (which appears to work fine), but I haven't been able to find documentation on OnQueryLoaded procedure.
- I will need to manually clear the cache should any updates occur.
Any comments on whether this approach is a good/bad idea would be appreciated.
Many thanks
Richard
I've added the following custom load function to the Collection business object
public bool Load(int CategoryID, int ObjectID)
{
string strKey = "CategoryCachePrefix_" + CategoryID + ":" + ObjectID;
if (HttpContext.Current.Cache[strKey] != null)
{
return this.OnQueryLoaded((DataTable)HttpContext.Current.Cache[strKey]);
}
else
{
Query.Select(Query.Name, Query.MoreFields1)
.Where
(
Query.CategoryID.Equal(CategoryID),
Query.ObjectID.Equal(ObjectID)
)
.OrderBy
(
Query.Name.Ascending
);
if (Query.Load())
{
HttpContext.Current.Cache[strKey] = this.Table;
return true;
}
else
return false;
}
}