Hello Andrew,
As for the ObjectDataSource control, its caching mechnism is managed by the
ObjectDataSourceView class (used internally) and if you have configured the
objectDataSource control to use cache , we can not manually invalid the
underlying cached object.
#ObjectDataSource.Selected Event
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat
asource.selected.aspx
For your three questions, here are my understanding:
1. Can I access the cached DataTable?
==============================
The ObjectDataSource control has defined a "Selected" event, and in this
event we can get the returned data object through the event argument. e.g.
protected void ObjectDataSource1_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
Response.Write("<br/>" + e.ReturnValue.GetType());
}
if the objectdatasource control is configured to use a
DataSet+TableAdapter, the returnValue is underlying datatable.
2. Can I invalidate the cache?
==============================
You can not manually invalid the underlying cached object.
3. What approach should I use if I need to filter the DataTable before
returning the results? I'd like to query the cached DataTable.
==============================
You can consider use the ReturnValue mentioned in #1
or more general, you can define a custom wrapper class around the original
data access class(like the DataSet+TableAdaper), on this wrapper class you
can define custom methods which will customize how to filter the raw
resultset returned by original data access class and return it to
ObjectDatasource control.
The ObjectDataSource control has an "ObjectCreated" event and we can access
the created class object( configured through "TypeName" attribute), thus
you can call any custom methods on that object(your wrapper class).
#ObjectDataSource.ObjectCreated Event
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat
asource.objectcreated.aspx
BTW, for the following things you mentioned:
=========================
PS. The documentation on using this is sketchy. Some mention's that I need
to add some infomation to the web.config file. I didn't. The documentation
says 'The ObjectDataSource supports only polling'. But what is this:
SqlCacheDependency="CommandNotification"? It kind of suggests it's using
the
SQL 2005 notification?
==========================
SQL 2005 natively support query notification through the
NotificationService while SQL Server 2000 doesn't. When using ASP.NET
SqlCacheDependency against SQL Server 2000, we need to add configuration in
web.config, and ASP.NET will use a background thread to poll the SQL Server
2000 database so as to make it work.
Hope this helps. If there is any other information you wonder, please feel
free to let me know.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.