Hi Andrew,
Thank you for posting.
Regarding on the ObjectDataSourc e's caching behavior , here are some of my
understanding and suggestion:
The objectDataSourc e control's cache is maintained internally so that we
can not manually view or query through the Page.Cache or HttpContext.Cac he
collection. And the cache is created and used during the Select method of
the ObjectDataSourc e, that means, when ObjectDataSourc e.Select method is
called, it will check the cache to see whether it should use cache or redo
the query from the underlying data access class. This is different from
the behavior GridView (or other databound control) call
DataSourceContr ol.Select since DataBound control may store data in
ViewState to avoid querying the datasourcecontr ol. In other word, if you
want to test the ObjectDatasourc e control's cache behavior, you can
manually call ObjectDataSourc e.Select method and also put some trace
code(like Httpcontext.Cur rent.Response.W rite...) in the data access
control's select method to check the behavior.
Also, for the "CacheKeyDepend ency", when it is set, that means the
ObjectDataSourc e.Select method will use the cached data only when there is
an existing cache entry in the application Cache and the key of it equals
to the "CacheKeyDepend ency" property wo set on the ObjectDataSourc e
control. So we need to add such a cache entry so that the ObjectDataSourc e
will use the cache, then, when we want to explicitly expire the
ObjectDataSourc e's cache, just remove that entry(we need to readd it if we
want the objectdatasourc e to begin using cache again). e.g:
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
CacheDuration=" 10"
EnableCaching=" True" SelectMethod="G etProducts"
TypeName="TestD ataObject" CacheKeyDepende ncy="MYKEY">
............... ..
//test method to manually call ObjectDatasourc e.Select method
protected void Button1_Click(o bject sender, EventArgs e)
{
Response.Write( "<br/>Button1_Click" );
ObjectDataSourc e1.Select();
}
//manually remove the cache entry of the objectdatasourc e's KeyDependency
protected void btnInvalid_Clic k(object sender, EventArgs e)
{
Cache.Remove(Ob jectDataSource1 .CacheKeyDepend ency);
}
// set the key entry
protected void Button2_Click(o bject sender, EventArgs e)
{
Cache[ObjectDataSourc e1.CacheKeyDepe ndency] = new object();
}
Hope this helps.
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)