Click here to Skip to main content
15,892,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

(Apologies for the length of this question. It is the result of some muddy thinking.)

I am designing a small website with an MSSQL DB, and I have just stumbled across the ObjectDataSource class. I think I understand what it does, but I am having trouble seeing how it relates to the traditional MVC design pattern.

The class, according to Microsoft, is designed to sit between the UI (View) and the database, and as such, I would be inclined to think of it as a Controller. It does indeed map button clicks etc. in the UI to behaviours (e.g. CreateNewProduct), but it also contains code for writing to the database, which is not something I would expect a traditional Controller to do.

It seems to me that it is performing the roles of being both the Controller and the Model, but I get the feeling I am not seeing something here. Also, where is the Model in all this? Is it simply the database? I think I am incorrect here. I think the Model is the business objects manipulated by the ObjectDataSource class, but if this is the case then the Controller (the ObjectDataSource?) is taking responsibility for persisting the business objects to the database.

Also, I have to question my belief that the ObjectDataSource is the Controller because it doesn't really seem to be managing how the UI (View) interacts with the business objects (Model). A change in a Datagrid, for example, simply gets written straight through to the database.

That's a lot of words to say I am very confused. I would be very grateful to anyone who can point out the many places I am making mistakes here.

Kind wishes ~ Patrick
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900