如何构建三层解决方案?
我在我的解决方案中使用 FluentNHibernate。 Fluentnhibernate 文档推荐的文件夹结构是这样的:
Entities 文件夹,在该文件夹下我们有业务模型的 POCO 类。 Mappings 文件夹,在该文件夹下有数据模型的映射。
我假设这两个文件夹将进入一个名为“BusinessModel”的业务层项目?参见下文:
BuessinessModel
|_ Entities
|- Student.cs
|- Course.cs
|- Faculty.cs
|_ Mappings
|- Mappings.cs
也许创建另一个名为“DataAccess”的项目,该项目引用数据访问层的 BusinessModel 项目来执行 CRUD?
最好的做法是什么?那里有建筑师吗?谢谢。
AK:我在 n-layered 上阅读了您的帖子架构 - BLL、DAL 和接口。最佳实践是什么?。
让我引用你的
以“人”为例:思考不同的数据 与一个人相关的操作(获取单个人的所有数据 person,许多人的浅层数据的集合,CRUD 操作、搜索等)-然后沿着逻辑设计接口 分组。
我正在尝试理解这一点。所以,你是说
在 BLL 项目中,我们有这个 Person 类。
此外,在 BLL 项目中,我们有一个声明所有数据的接口 我们需要 Person 对象的操作方法。
然后在DAL项目中,我们有具体的实现 我们在BLL中定义的接口。
您觉得这听起来正确吗?谢谢。
I am using FluentNHibernate in my solution. The recommended folder structure from fluentnhibernate documenation is like this:
Entities folder, under which we have POCO classes of the business model.
Mappings folder, under which we have the mappings to our data model.
I assume that these two folders would go into a business layer project called "BusinessModel"? See below:
BuessinessModel
|_ Entities
|- Student.cs
|- Course.cs
|- Faculty.cs
|_ Mappings
|- Mappings.cs
And maybe create another project called "DataAccess" which references the BusinessModel project for the data access layer to do the CRUD?
What's the best practice? Any architect there? Thanks.
AK: I read your post at n-layered architecture - BLL, DAL and interfaces. What is best practice? .
Let me quote yours
Taking a "Person" as an example: think about the different data
operations associated with a person (Getting all the data for a single
person, a collection of shallow data for many persons, CRUD
operations, searching, etc) - then design interfaces along logical
groupings.
I am trying to understand this. So, you are saying that
In the BLL project, we have this Person class.
Also in the BLL project, we have an interface which declares all data
operation methods we will need for the Person object.Then in the DAL project, we have concrete implementation of the
interface we define in BLL.Does this sound correct to you? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然盲目地将相同的架构应用于每个解决方案/项目是危险的;我的标准/默认方法是这样的:
高级别
您的具体细节
其他说明
While it's dangerous to go blindly applying the same architecture to every solution / project; my standard / default approach would be something like this:
High Level
Your Specifics
Other Notes
您需要将具体数据访问与业务层分开,最好创建一个具有实体(域模型)和存储库接口的业务层。
然后创建数据访问的具体实现,其中包括使用 FluentnHibernate 进行数据访问的映射和具体存储库。
商业性
|_ 实体
|- Student.cs
|- 课程.cs
|- 学院.cs
|_ 存储库接口
|- IStudentRepository.cs
|- ICourseRepository.cs
DAL(具体 - 使用 FluentNHibernate)
|_ 映射
|- 映射.cs
|_ 存储库
|- StudentRepository.cs
|- CourseRepository.cs
You need to separate the concrete data access from the business layer, preferable to create a business layer with entities (domain model) and repository interfaces.
Then create a concrete implementation of Data access which includes mappings and concrete repositories for data access using fluentnhibernate.
Buessiness
|_ Entities
|- Student.cs
|- Course.cs
|- Faculty.cs
|_ RepositoryInterfaces
|- IStudentRepository.cs
|- ICourseRepository.cs
DAL (Concrete - using FluentNHibernate)
|_ Mappings
|- Mappings.cs
|_ Repositories
|- StudentRepository.cs
|- CourseRepository.cs