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 BOOLInentitytransactiontest (stringMainid,stringdetailid) {    //can support any popular database type and specify the relevant database provider (Oracleprovider, SQLProvider, Sqliteprovider, Mysqlprovider, Db2provider, Oledbprovider)Idbprovider Dbprovider =NewOracleprovider (systeminfo.businessdbconnectionstring); BOOLresult =true; Try{dbprovider.begintransaction (); //Main TableCase_productin_mainmanager Manager =NewCase_productin_mainmanager (Dbprovider, utils.userinfo); Case_productin_mainentity mainentity=Manager.        GetEntity (Dbprovider.sqlsafe (Mainid)); Manager.        Delete (mainentity); //child tableCase_productin_detailmanager Detailmanager =NewCase_productin_detailmanager (Dbprovider, utils.userinfo); Case_productin_detailentity detailentity=detailmanager.getentity (Dbprovider.sqlsafe (detailid));        Detailmanager.delete (detailentity); //Transaction Commitdbprovider.committransaction (); }    Catch(Exception ex) {//Transaction Rollbackdbprovider.rollbacktransaction (); Result=false; }    returnresult;}
  2. Incoming SQL statement transaction Test
Private BOOLInsqltransactiontest (stringMainid,stringdetailid) {            //can support any popular database type and specify the relevant database provider (Oracleprovider, SQLProvider, Sqliteprovider, Mysqlprovider, Db2provider, Oledbprovider)Idbprovider Dbprovider=NewSQLProvider (systeminfo.businessdbconnectionstring); BOOLresult =true; Try{dbprovider.begintransaction (); //Main Table                stringSqlmain =string. Format ("DELETE from Case_productin_main WHERE ID = {0}", Mainid);                Dbprovider.executenonquery (Sqlmain); //child table                stringSqldetail =string. Format ("DELETE from case_productin_detail WHERE ID = {0}", Detailid);                Dbprovider.executenonquery (Sqlmain); //Transaction Commitdbprovider.committransaction (); }            Catch(Exception ex) {//Transaction Rollbackdbprovider.rollbacktransaction (); Result=false; }            returnresult; }

Erichu Source: http://www.cnblogs.com/huyongEmail: [Email protected]qq exchange: 406590790 Platform Blog: "CSDN" http://blog.csdn.net/ Chinahuyong         "Cnblogs" Http://www.cnblogs.com/huyong 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.

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.