ASP MVC/EF 4 设计 - 是否使用视图模型?

发布于 2024-11-19 22:40:35 字数 164 浏览 7 评论 0原文

我有一个代表视频游戏评论的有点复杂的实体图列表。我将根据图表的属性(游戏标题、平台名称、类型)创建单独的导航。最终,它将像 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以笙箫默 2024-11-26 22:40:35

将信息传递到视图时使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文