Rdiframework.net framework compatible with various database type transactions use example reference

Source: Internet
Author: User

Rdiframework.net framework compatible with various database type transactions use example reference

The rdiframwork.net framework has a good control over the transaction of the database, it provides good support for the execution of multiple tables or multiple statements in the same transaction, and supports any major type of database, the following code can be used as a reference for the user. Users can use any extension.


1. Incoming entities perform execution transaction testing
Private bool inentitytransactiontest (string mainid,string detailid) {     //can support any popular database type, specifying the relevant database provider (Oracleprovider, SQLProvider, Sqliteprovider, Mysqlprovider, Db2provider, Oledbprovider)     idbprovider dbprovider = new oracleprovider ( systeminfo.businessdbconnectionstring);      bool result = true;         try    {         dbprovider.begintransaction ();         //Main Table          case_productin_mainmanager manager = new case_ Productin_mainmanager (dbprovider, utils.userinfo);         case_ Productin_mainentity mainentity = manager. GetEntity (Dbprovider.sqlsafe (Mainid));         manager.Delete (mainentity);        //Sub-table          case_productin_detailmanager detailmanager = new case_productin_detailmanager ( Dbprovider, utils.userinfo);         case_productin_detailentity  detailentity = detailmanager.getentity (Dbprovider.sqlsafe (detailid));         detailmanager.delete (detailentity);                //Transaction Submission                  dbprovider.committransaction ();    }         catch  (Exception ex)     {                 //Transaction Rollback                   dbprovider.rollbacktransaction ();         result = false;    }         Return result;}
2, incoming SQL statement transaction test
private bool insqltransactiontest (string mainId,  String detailid) {//can support any popular database type, specify the relevant database provider (Oracleprovider, SQLProvider, Sqliteprovider, Mysqlprovider, Db2provider, Oledbprovider) Idbprovider dbprovider = new sqlprovider ( systeminfo.businessdbconnectionstring); bool result = true;try{dbprovider.begintransaction ();// Main Table string sqlmain = string. Format ("delete from case_productin_main where id = {0}",  mainId); Dbprovider.executenonquery (Sqlmain);//child table string sqldetail = string. Format ("delete from case_productin_detail where id = {0}",  detailId); Dbprovider.executenonquery (Sqlmain);//Transaction commit dbprovider.committransaction ();} catch  (Exception ex) {//Transaction rollback dbprovider.rollbacktransaction (); result = false;} Return result;} 
Erichu Source: Email: [Email protected]qq exchange: 406590790 Platform Blog:
About senior engineer, information System Project Manager, DBA. Focus on Microsoft Platform Project architecture, management and enterprise solutions, multi-year project development and management experience, has organized and developed several large projects, proficient in dotnet,db (SQL Server, Oracle, etc.) technology. Familiar with Java, DELHPI and Linux operating system, have solid network knowledge. has some attainments in object-oriented, service-oriented and database fields. Currently engaged in DB management and development, WinForm, WCF, WebService, Web page Data capture and ASP, such as project management, development, architecture and other work. If you have any questions or suggestions, please enlighten me! This article is copyright to the author and Cnblogs blog, welcome to reprint, but without the author's consent must retain this paragraph statement, and in the article page obvious location to the original connection, if there is a problem, you can contact me by email or QQ, thank you very much.

650) this.width=650; "src=" http://images.cnitblog.com/i/157572/201405/041429355177306.jpg "width=" "height=" 90 "Style=" border:0px; "/>


This article is from ". NET rapid Development Framework blog, be sure to keep this source http://yonghu.blog.51cto.com/8166136/1600509

Rdiframework.net framework compatible with various database type transactions use example reference

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.