Encapsulate the enterprise database and enable the transaction solution at the business layer (code that can be used directly)

Source: Internet
Author: User

For the reason why we want to do this, please read it here and I believe it is what many people want.

Http://www.cnblogs.com/mimijidi/archive/2009/05/01/1447493.html

 

This solution is extracted from a previous project.

The company name will not be mentioned, and you will know it at a glance.

 

The following is an example of the business-layer call code:

Code

 using System;
using Demo.DAL;
using Framework.Service;

namespace Demo.BLL
{
public class ProductBll : ServiceBase
{
public void Update()
{
BeginTransaction();
try
{
ProductDal pd = new ProductDal();
pd.Update1();
pd.Update2();
Commit();
}
catch (Exception e)
{

Rollback();
throw new Exception(e.Message, e);
}
}

}

public static class ProductBll2
{
public static void Update()
{
ServiceBase.BeginTransaction();
try
{
ProductDal pd = new ProductDal();
pd.Update1();
pd.Update2();
ServiceBase.Commit();
}
catch (Exception e)
{
ServiceBase.Rollback();
throw new Exception(e.Message, e);
}
}
}
}

 

:

Http://files.cnblogs.com/builderman/Framework.rar

 

 

You are welcome to discuss this solution.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.