public void TransactionScope_ShouldNotPromoteToDTC2() { TestTool.RunTasks(10, () => { using (var txScope = AdoTool.CreateTransactionScope()) { var count = TotalCount(); var ds = NorthwindAdoRepository.ExecuteDataSetBySqlString(SQL_REGION_SELECT, 1, 10); var dt = NorthwindAdoRepository.ExecuteDataTableBySqlString(SQL_REGION_SELECT, 1, 10); Assert.IsFalse(ds.Tables[0].HasErrors); Assert.IsFalse(dt.HasErrors); int rows = NorthwindAdoRepository.ExecuteNonQueryBySqlString(SQL_REGION_INSERT); Assert.AreEqual(1, rows); rows = NorthwindAdoRepository.ExecuteNonQueryBySqlString(SQL_REGION_INSERT2); Assert.AreEqual(1, rows); NorthwindAdoRepository.ExecuteNonQueryBySqlString(SQL_REGION_DELETE); ds = NorthwindAdoRepository.ExecuteDataSetBySqlString(SQL_REGION_SELECT); dt = NorthwindAdoRepository.ExecuteDataTableBySqlString(SQL_REGION_SELECT); txScope.Complete(); } }); }
public void ExecuteDataSet(int firstResult, int maxResults) { DataSet ds; using (var cmd = NorthwindAdoRepository.GetCommand(GetOrderDetailsSql)) using (ds = NorthwindAdoRepository.ExecuteDataSet(cmd, firstResult, maxResults)) { Assert.AreEqual(ds.Tables.Count, 1); Assert.IsFalse(ds.Tables[0].HasErrors); Assert.Greater(ds.Tables[0].Rows.Count, 1); Console.WriteLine("RowCount: " + ds.Tables[0].Rows.Count); } using (ds = NorthwindAdoRepository .ExecuteDataSetBySqlString(GetOrderByOrderDateAndFreightAndCustomerSql, firstResult, maxResults, new AdoParameter("OrderDate", DateTime.Today), new AdoParameter("Freight", 2), CustomerTestParameter)) { Assert.AreEqual(ds.Tables.Count, 1); Assert.IsFalse(ds.Tables[0].HasErrors); // Assert.Greater(ds.Tables[0].Rows.Count, 1); Console.WriteLine("RowCount: " + ds.Tables[0].Rows.Count); } }
public void ExecuteDataSetWithParameter() { var query = NorthwindAdoRepository.QueryProvider.GetQuery("Order Details, GetByOrder"); using (var ds = NorthwindAdoRepository.ExecuteDataSetBySqlString(query, base.OrderTestParameter)) { Assert.AreEqual(ds.Tables.Count, 1); Assert.IsFalse(ds.Tables[0].HasErrors); Assert.Greater(ds.Tables[0].Rows.Count, 0); } }
public void UseTransactionScope() { AdoWith.TransactionScope(ExecuteDataSet, ExecuteDataSetWithParameter, ExecuteDataSetByProcedure); var query = NorthwindAdoRepository.QueryProvider.GetQuery("Order Details, GetAll"); AdoWith.TransactionScope( () => { using (NorthwindAdoRepository.ExecuteDataSetBySqlString(query)) {} }, () => { } ); }
public void ExecuteDataSetByPaging(int firstResult, int maxResults) { DataSet ds = null; using (var cmd = NorthwindAdoRepository.GetCommand(GetOrderDetailsSql)) using (ds = NorthwindAdoRepository.ExecuteDataSet(cmd, firstResult, maxResults)) { Assert.AreEqual(ds.Tables.Count, 1); Assert.Greater(ds.Tables[0].Rows.Count, 0); Console.WriteLine("RowCount=[{0}]", ds.Tables[0].Rows.Count); } using (ds = NorthwindAdoRepository.ExecuteDataSetBySqlString(GetOrderDetailsSql, firstResult, maxResults)) { Assert.AreEqual(ds.Tables.Count, 1); Assert.Greater(ds.Tables[0].Rows.Count, 0); Console.WriteLine("RowCount=[{0}]", ds.Tables[0].Rows.Count); } }
public void TransactionScope_ShouldNotPromoteToDTC3() { TestTool.RunTasks(10, () => AdoWith.TransactionScope(TransactionScopeOption.Required, System.Transactions.IsolationLevel.ReadCommitted, delegate { var count = TotalCount(); }, delegate { NorthwindAdoRepository.ExecuteNonQueryBySqlString(SQL_REGION_INSERT); NorthwindAdoRepository.ExecuteNonQueryBySqlString(SQL_REGION_INSERT2); NorthwindAdoRepository.ExecuteNonQueryBySqlString(SQL_REGION_DELETE); }, delegate { var ds = NorthwindAdoRepository.ExecuteDataSetBySqlString( SQL_REGION_SELECT, 1, 10); }, delegate { var dt = NorthwindAdoRepository.ExecuteDataTableBySqlString( SQL_REGION_SELECT, 1, 10); } )); }