MyPDO 2.0 supports business logic layer transactions

xiaoxiao2021-03-04  58

MyPDO 2.0 supports business logic layer transactions

Download http://free.ys168.com/?yu-nan88

Document Trans1.cs

Using system;

Using nunit.framework; uspdo.dataaccess;

Summary description of Namespace TestData {///

/// TRANS1. /// [TestFixTure] public class trans1 {public trans1 () {// // Todo: Add Construction Function Logic // DBA = New DataAccessor (); dba.connectString = "DATA SOURCE = 10.10 .35.30; Initial catalog = tradecityt; Persist security info = false; user ID = sa; pwd = lee; "; //" provider = sqloledb; data source = 10.10.25.63; initial catalog = master; user ID = zha; password = 123; "; DBA.ConnectType = MyPDO.ConnectType.SqlDataDriver; DBA.Open ();} private MyPDO.DataAccess.DataAccessor DBA; public MyPDO.DataAccess.DataAccessor Data {get {return DBA;} set {DBA = value; }

[Setup] public void setup () {//this.connectString = "data source = 10.10.35.37; initial catalog = tradecityt; persist security info = false; user ID = sa; pwd = 123;"; //this.connecttype = MyPDO.CONNECTTYPE.SQLDATADRIVER; Assert.isTrue (DBA.isopen, "DBA Closed");} public int insert () {string str = "INTO T_BASE_MANAGER (Managercode, State2) VALUES ('Test1', 1)" DBA.Commandtext = Str; INT i = dba.executeCommand (false); assert.istrue (i == 1); return i;}

}

Document Trans2.cs

Using system;

Using nunit.framework; uspdo.dataaccess;

Summary description of Namespace TestData {///

/// TRANS1. /// [testfixture] public class trans2 {public trans2 () {// // TODO: Add constructor logic //

DBA = new DataAccessor (); DBA.ConnectString = "data source = 10.10.35.30; initial catalog = TradeCityT; persist security info = False; user id = sa; pwd = lee;"; // "Provider = SQLOLEDB; data source = 10.10.25.63; Initial catalog = master; user ID = zha; password = 123; "; dba.connecttype = mypdo.connecttype.sqldataDriver; dba.open ();} private mypdo.dataaccess.dataAccessor DBA;

public MyPDO.DataAccess.DataAccessor Data {get {return DBA;} set {DBA = value;}} [SetUp] public void SetUp () {//this.ConnectString = "data source = 10.10.35.37; initial catalog = TradeCityT; Persist security info = false; user ID = sa; pwd = 123; "; //this.connecttype = mypdo.connecttype.sqldataDriver; assert.istrue (dba.isopen," dba closed ");} public int insert () { //Dba.autocommit = false; string str = "INSERT INTO T_BASE_MANAGER ('Test2_1', 1)"; dba.commandtext = Str; INT I = this.insert (); if (i == 1) {str = "INTO T_BASE_MANAGER (Managercode, State) VALUES ('Test2_2', 1)"; DBA.CommandText = Str; i = this.insert ();} assert.istrue (2 == i); // if (i == 2) // dba.commitTrans (); // else // dba.rollbackTrans (); return i;} private int insert () {INT i = dba.executeCommand (false); assert. Istrue (i == 1); returni}}}}

Document testdata.cs

Using system;

Using nunit.framework; uspdo.dataaccess;

Namespace TestData {///

/// TestData's summary description. /// [testfixture] public class testdata {public testdata () {// // TODO: Add constructor logic //} private mypdo.dataaccess.DataAccessor DBA; [Setup] Public Void Setup ) {//this.ConnectString = "data source = 10.10.35.37; initial catalog = TradeCityT; persist security info = False; user id = sa; pwd = 123;"; //this.ConnectType = MyPDO.ConnectType.SqlDataDriver;

DBA = new DataAccessor (); DBA.ConnectString = "data source = 10.10.35.30; initial catalog = TradeCityT; persist security info = False; user id = sa; pwd = lee;"; // "Provider = SQLOLEDB; data source = 10.10.25.63; Initial catalog = master; user ID = zha; password = 123; "; DBA.ConnectType = mypdo.connecttype.sqldataDriver; dba.open (); assert.isopen (DBA.isopen," dba closed ") } [Test] public void trans_test () {string str = "Insert INTO T_BASE_MANAGER ('Test3', 1)"; dba.autocommit = false; dba.commandtext = Str; INT i = DBA. ExecuteCommand (False);

AskERT.ISTRUE (i == 1);

IF (i == 1) {

Console.write (I.toTString () "/ n");

TRANS2 TS2 = New Trans2 (); ts2.data = DBA; i = ts2.insert ();

Console.write (I.toTString () "/ n");

Assert.istrue (i == 3); if (i == 3) {Trans1 TS1 = New Trans1 (); ts1.data = dba; i = ts1.insert ();

Console.write (I.toTString () "/ n");

}

IF (i == 4) dba.committrans (); else dba.rollbacktrans ();

Console.write (I.toTString () "/ n");

}}}

转载请注明原文地址:https://www.9cbs.com/read-31695.html

New Post(0)