I submitted a bug report lately on the fact that the Object DataSource throws an exception when you try to enable caching on anything else then a datatable or a dataset. Great news, the bug suggestion got picked up by others and people started to vote for my bug report. This got picked up by the ASP.NET team and….. they now support caching of DataTables, DataSets, DataViews, and arbitrary IEnumerables. Here is an excerpt of the feedback I got:
Good news: We now support caching of DataTables, DataSets, DataViews, and arbitrary IEnumerables. Here’s a summary of the behavior:
1. DataSet/DataTable:
Caching is always permitted, as well as filter expressions and automatic sorting.
2. DataView:
Caching is permitted unless there is a sort expression. If there is a sort expression we throw because otherwise multiple data bound controls will get back conflicting sorted DataViews. Filtering is never supported with DataView (since it could conflict with an existing row filter).
3. IEnumerable and single objects (e.g. a business object that returns a single Product object, not wrapped in an IEnumerable).
We always allow caching of these objects (except one case, noted below). Sorting and filtering are never supported on these objects (we throw).
If the object implements IDataReader (for example the business object returns a SqlDataReader) and caching is enabled, we throw an exception.
It’s just great to see that they are listening on the other end of the wire.
Many thanks to the ASP.NET team!