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