持久层在任何应用程序中的用途是什么? [英] What is the use of a persistence layer in any application?

查看:110
本文介绍了持久层在任何应用程序中的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须创建一个应用程序,要求我在该应用程序中创建一个持久层。该应用程序位于.net中。我已经创建了一个业务层和一个表示层,但是我不知道如何以及为什么应该创建一个持久层。

I have to create an application in which I am asked to create an persistence layer in the application. The application is in .net. I have created a business layer and a presentation layer but I don't know how and why I should create a persistence layer.

我用谷歌搜索并了解了该持久层通常用于从数据库存储和检索数据。

I googled and came to know that persistence layer is used for storing and retrieving data usually from a database.

有人可以详细解释吗?

推荐答案

之所以在数据库引擎和业务/应用程序逻辑之间构建DAL(数据访问层)或任何其他类型的中间层,是因为通过在两者之间添加此层来隔离其余部分

the reason for you to build a DAL ( Data Access Layer ) or any other kind of intermediate layer between database engine and Business / Application logic, is that by adding this layer in the between you isolate the rest / upper layers of your application from the specific database engine / technology you are using right now.

这具有几个优点,例如更容易迁移到其他存储引擎,更好的封装单层中的数据库逻辑(根据您对跨层接口的设计程度等,以后更容易替换或修改...)

This has several advantages, like easier migration to other storage engines, better encapsulation of database logic in a single layer ( easier to replace or modify later depending on how well you have designed your cross-layer interfaces etc...)

在这里查看我的答案,这是一个关于ASP.NET MVC和EF,但解决方案和项目的结构实际上与技术无关: MVC3和实体框架

see my answer here, it is an example about ASP.NET MVC and EF but the structuring of solution and projects is actually technology independent: MVC3 and Entity Framework

也请阅读一些文章以更好地理解此问题,例如: http://www.developerfusion.com/article/84492/net-and-data-persistence/

Also read some articles to better understand this matter, for example: http://www.developerfusion.com/article/84492/net-and-data-persistence/

这篇关于持久层在任何应用程序中的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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