ObjectDataSource如何与传统的MVC模式相关联? [英] How does the ObjectDataSource relate to the traditional MVC pattern?

查看:79
本文介绍了ObjectDataSource如何与传统的MVC模式相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





(对于这个问题的长度抱歉。这是一些泥泞思维的结果。)



我正在设计一个带有MSSQL DB的小型网站,我偶然发现了 ObjectDataSource 类。我想我明白它的作用,但我很难看到它与传统MVC设计模式的关系。



根据微软的说法,该课程旨在坐在UI(视图)和数据库之间,因此,我倾向于将其视为控制器。它确实将UI中的按钮点击等映射到行为(例如CreateNewProduct),但它也包含用于写入数据库的代码,这不是我期望传统Controller做的事情。



在我看来,它正在扮演控制器和模型的角色,但我感觉我在这里没有看到什么。此外,所有这些模型在哪里?它只是数据库吗?我想我在这里不正确。我认为Model是由 ObjectDataSource 类操纵的业务对象,但如果是这种情况,则Controller( ObjectDataSource ?)负责持久化业务对象数据库。



此外,我不得不质疑我认为 ObjectDataSource 是控制器,因为它似乎并不真的如此管理UI(视图)如何与业务对象(模型)交互。例如,Datagrid中的更改只是直接写入数据库。



这说的很多话我很困惑。我非常感谢任何能指出我在这里犯错的地方的人。



亲切的愿望~Patrick

解决方案

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

解决方案

这篇关于ObjectDataSource如何与传统的MVC模式相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆