ASP MVC/EF 4 设计 - 是否使用视图模型?
我有一个代表视频游戏评论的有点复杂的实体图列表。我将根据图表的属性(游戏标题、平台名称、类型)创建单独的导航。最终,它将像 Wiki 一样。
我想知道的是 - 我应该在控制器中获取这些导航信息并将其全部存储在视图模型中,还是应该简单地将图表列表传递到视图中并在那里进行操作?在这种情况下,这重要吗?
I have a list of somewhat complex entity graphs representing video game reviews. I'm going to create separate navigation based on the graphs' properties - game title, platform name(s), genre. At the end, it will be Wiki-like.
What I'm wondering is this - should I do the work to grab this navigation info in my controller and store it all in a view model, or should I simply pass my list of graphs into the view, and manipulate it there? Does it matter, in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将信息传递到视图时使用 ViewModel 是一个很好的约定。 ViewModel 建议指向视图的链接。在完美的世界中,我们将为每个视图使用 1 个 ViewModel,
有一个 Jimmy Bogard(《MVC 3 in Action》的作者)撰写的精彩文章,可以在这里提供帮助
IT is good convention to use a ViewModel when passing information to the views. ViewModel suggests a link to a View. In a perfect world then we would use 1 ViewModel per View
there is a great article by Jimmy Bogard (author of MVC 3 in Action) that could help here