views:

78

answers:

1

I've never had the need to really ever use any of the .NET Data sources other than the SiteMap datasource however I'm trying to take advantage of the built in CRUD operations on a control which needs to be assigned a data source to correctly work.

As I've been working through information online about implementing the ObjectDataSource and its related classes I've realized what was so glaringly unsettling about it, the fact it drives off basically a static class that is supposed to magically be able to handle the CRUD operations of a type. Once this dawned on me I couldn't see anyway to correctly design these adapters so they don't bleed concern like a hemophiliac.

The only ideas I've come up with is if the class leverages the Service Locator pattern inside each of it's operations to get the correct class for doing the actual CRUD. Which would be somewhat doable by just using .Resolve from an inversion of control container, however this seems like then I would just be shifting the concern to an even less obvious place by needing to do lots of magic with my IOC framework to always resolve the correct instance of the data proxy.

All I really need the adapter to do is to mediate calls to apply CRUD operations to ViewState backed IList<MyBizObject>.

After doing some more pondering on this as I've been writing the question I started to think about how I use the Model-View-Presenter pattern for logic separation my first solution I see is since my Presenter class has a property for my View on it that I could use Container.Resolve<Presenter>() which would give me access to my View which would give me access to my ViewState backed field and to create a class for each presenter that needs it's view to have an ObjectDataSource.

Does anyone else have any input or alternatives than my last thoughts on this?

A: 

To answer my own question, yes it just really sucks. However with service locator pattern it's possible to expose your stateful page viewstate or any other type of stateful repository to a stateless object datasource provider class.

Chris Marisic
Love the DV without one argument against my words, I stand by my answer. A class that expects static methods sucks.
Chris Marisic