views:

55

answers:

1

I'd like to use ObjectDataSource with an instance that implements IRepository. I'd also like to be able to flexibly change the IRepository implementation through dependency injection, and switch between one that uses ORM and a fake.

I currently don't see a way to do this because the ODS points to a class instead of an instance. Is there a way around this?

I'm looking along the lines of having a data source class that calls a factory that creates the appropriate IRepository implemenation depending on configuration settings. However, I will have to create the implementation everytime this data source class is called, which may be expensive.

A: 

I'm not 100% sure what you're trying to do, but I think you'll have to handle the ODS's "ing" events: ObjectCreating, ObjectInserting, etc. By handling these events you can use any data access strategy you want. Of course if you follow this path then the ODS adds little value to your application.

Manuel Abadia has written an excellent series of articles that discuss the limitations of the ODS control.

Jamie Ide
Thanks for your reply. I simply want to take advantage of the sorting and paging capabilities of the ODS control to speed up development, while at the same time without coupling my presentation layer to the data access layer. I will check your links out. Thanks!
Jason Banico
Then I have more bad news for you ... you'll also have to handle sorting and paging yourself.
Jamie Ide
I will give my static data source facade class a try and see if that works...
Jason Banico