ObjectDataSource如何与传统的MVC模式相关联?

编程入门 行业动态 更新时间:2024-10-24 12:21:35
本文介绍了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模式相关联?

本文发布于:2023-10-19 14:46:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1507835.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:相关联   模式   与传统   ObjectDataSource   MVC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!