ASP.NET MVC 3 ViewModels 在不同的项目中?
有什么可以阻止您将 ViewModel 放置在不同的项目中吗?
我基本上有一个 DataModel(实体框架)项目、数据访问项目(可能会将其合并到 DataModel 中)、业务逻辑项目和 ASP.NET MVC 网站。我希望业务逻辑层返回 ViewModel,因此想知道这些是否可以与网站代码分开。
Is there anything from stopping you placing ViewModels in a different project?
I basically have a DataModel (Entity Framework) project, Data Access project (might merge this into the DataModel), Business Logic project and the ASP.NET MVC website. I want the Business Logic layer to return ViewModels so was wondering if these can be separate from the website code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
绝对可以 - 您只需要在 MVC3 项目中引用 DLL,然后在强类型视图中引用这些 ViewModel。
只需确保您
在视图顶部声明,以使它们成为强类型。
Absolutely - you just need to reference the DLL in your MVC3 project and then reference those ViewModels in your strongly typed views.
Just make sure you declare
At the top of your views to make them strongly typed.
简短的回答:没有
长的回答:没有理由。这将使您必须更多地考虑项目引用和位的依赖关系。当涉及到参考资料等时,您只需要小心设计即可。
希望有所帮助。
另外,可以帮助进行单元测试:-)
Short answer : no
Long answer : no reason. It will make you have to think more about dependencies of project references and bits. You'll just have to be careful with the design when it comes to references etc.
Hope that helps.
Also, can help with unit testing :-)