如何保持N层架构交易 [英] How To Maintain Transaction in N-Tier Architecture

查看:120
本文介绍了如何保持N层架构交易的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的N层体系结构的应用程序。因为我们都知道,我们需要实现的事务,同时插入/更新/删除操作。请告诉我如何在N层架构使用C#.NET交易。
我的建筑是这样的
Applicationform-> middle_Layre->厂 - > DataAccessLayre-> StoredProcedure->表
申请表我创建middleLayer的对象,并在插入/更新的数据传递/删除中间层的功能。
我创建的factoryclass的SqlCommand对象,并填写这是我从中间层获得的数据和对象OS的SqlCommand传递给DAL。

I am developing application in N-Tier Architecture. as we all know that we need to implement transactions while insert/update/delete operation. please tell me how to use transaction in c#.net in N-Tier architecture. my architecture is like this Applicationform->middle_Layre->Factory->DataAccessLayre->StoredProcedure->Table in application form i create object of middleLayer and pass data in Insert/update/delete function of middle layer. i am creating object of sqlcommand in factoryclass and fill the data which i gets from middle layer and pass that object os sqlcommand to DAL.

推荐答案

下面是一个软件层重新presentative模式可以遵循:

Here is a representative pattern of software layers you can follow:

Database <-> DAL <-> Repository <-> BLL <-> Controller <-> View Model <-> UI

其中,

DAL == Data Access Layer (aka ORM, Object-Relational mapper)
BLL == Business Logic Layer*

在此模型中,交易发生在Repository,其中布置一个工作单元。通常情况下,这种情况从DAL请求数据,对其执行工作,并保存更改。该DAL一般会环绕你的工作单位的事务。

In this model, the transaction takes place in the Repository, where a "unit of work" is arranged. Typically, this happens by requesting data from the DAL, performing work on it, and saving changes. The DAL will generally wrap a transaction around your unit of work.

数据库,DAL,库和BLL共同形成所谓的MVC(模型 - 视图 - 控制器)架构模型。所有的业务逻辑和数据处理发生在模型中。该控制器充当穿针引线的模型和视图模型/ UI,它们共同形成视图之间。

The Database, DAL, Repository and BLL collectively form what is known as the Model in MVC (Model-view-controller) architecture. All business logic and data manipulation takes place in the Model. The controller acts as a go-between between the model and the View Model/UI, which collectively form the view.

该库是您将设置你的工作单元。

The Repository is where you would set up your "Unit of Work."

* <子>可选

这篇关于如何保持N层架构交易的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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