.NET N层架构:我该怎么办有关模型对象?我该、架构、模型、对象

2023-09-04 08:27:54 作者:一个人的生活

我是从头开始创建一个解决方案,使用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:

在UI调用BLL方法传入填充数据模型对象。 BLL调用DAL的方法穿过物体它被保存 在数据库等。 UI calls a method in BLL passing in a model object filled with data. 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...