ObjectDataSource limitations

Wednesday, August 02, 2006

One of the more exciting things in Visual Studio 2005 for me was the idea of an object data source for grids. Well, I'm not doing a lot of hands on programming right now, and I finally got around to using it. I'm not that thrilled. Here's a snippet from a help file that is my current source of frustration:

The ObjectDataSource control will create an instance of the source object, call the specified method, and dispose of the object instance all within the scope of a single request, if your object has instance methods instead of static methods (Shared in Visual Basic). Therefore, your object must be stateless. That is, your object should acquire and release all required resources within the span of a single request.
This pretty much means that they expect an object to be a pass through to some other data source (XML, DB, etc.). I'm just capturing some session information right now. I find it easier to create/populate an object and databind directly then try to make an object that's specific to this problem. I think for the time being I'll go that route...


Swiftus said...

It's designed to force a O/R model upon your data. The whole idea of the object data source was to abstract *everything* data related from the UI. From my observation, the entire world is going to the factory model when it comes to data access (EntLib for example). In fact, with the new LINQ extensions, there will be a Microsoft sanctioned O/R model for ADO. All of which is completely stateless and folds well into the ObjectDataSource control.

Emil's Wicked Cool Blog