.NET N层架构:我该怎么办有关模型对象? [英] .NET N-Tier Architecture: What do I do about the Model objects?

查看:208
本文介绍了.NET N层架构:我该怎么办有关模型对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从头开始创建一个解决方案,使用ASP.NET Web窗体C#。

I am creating a solution from scratch, using ASP.NET Web forms C#.

我关注的模型对象,因为我不希望在每一层创建模型对象的副本集。什么是使用模型对象的3层建筑 Web窗体最佳实践

I am concerned about the model objects as I don't want to create duplicate sets of model objects in each layer. What is the best practice for using Model objects in 3 layer architecture in Web Forms?

我心目中的结构如下:

  • 在UI
  • BLL
  • DAL
  • 型号

该模型将包含所有模型的可在层的每个部分使用。我想作为每一层需要访问模型对象,这将是有益的。例如:

The Model will contain all the model classes that can be used in each section of the layers. I thought this would be useful as each layer needs access to the model objects. For example:

  1. 在UI调用BLL方法传入填充数据模型对象。
  2. BLL调用DAL的方法穿过物体它被保存 在数据库等。
  1. UI calls a method in BLL passing in a model object filled with data.
  2. BLL calls a method in DAL passing through the object which is saved in the database etc.

感谢

推荐答案

看我的答案在这里: http://stackoverflow.com /一/五十五万九千一百四十四分之七百四十七万四千三百五十七这是通常的方式,我做的事情,并且效果很好,不仅对MVC和实体框架......其实在MVC模型可能是其中只有一些字段的实体类型通过包含在较低层中定义的真正的商业实体,它取决于如果你真的确实需要在UI级别的所有字段以及或只有一些做一些数据呈现和输入...

look at my answer here: http://stackoverflow.com/a/7474357/559144  this is the usual way I do things and works well, not only for MVC and Entity Framework... in fact in MVC the model could be an entity type which only has some of the fields contained by the real business entities defined in lower layers, it depends if you really absolutely need all fields in the UI level as well or only some to do some data rendering and input... 

这篇关于.NET N层架构:我该怎么办有关模型对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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