Example #1
0
        public void RecordsAreNotSavedwhenLoadDataSetStoredProcCommandAndTransactionRollback()
        {
            OracleDatabase db           = (OracleDatabase)DatabaseFactory.CreateDatabase("OracleTest");
            DataSet        dsCountry    = new DataSet();
            DbCommand      dbAddCountry = db.GetStoredProcCommand("AddCountryListAll");

            db.AddInParameter(dbAddCountry, "vCountryCode", DbType.String, "SCO");
            db.AddInParameter(dbAddCountry, "vCountryName", DbType.String, "Scotland");
            DbCommand dbAddCountry1 = db.GetStoredProcCommand("AddCountryListAll");

            db.AddInParameter(dbAddCountry1, "vCountryCode", DbType.String, "SCO");
            db.AddInParameter(dbAddCountry1, "vCountryName", DbType.String, "Scotland");

            using (DbConnection connection = db.CreateConnection())
            {
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();
                try
                {
                    db.LoadDataSet(dbAddCountry, dsCountry, "Country", transaction);
                    db.LoadDataSet(dbAddCountry1, dsCountry, "Country", transaction);
                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }
            string countryName = (string)db.ExecuteScalar(CommandType.Text, "select countryName from Country where CountryCode='SCO'");

            Assert.IsNull(countryName);
        }
Example #2
0
        public void DataIsLoadedWhenLoadDataSetUsingStoredProcCommandAndMultipleTables()
        {
            OracleDatabase db        = (OracleDatabase)DatabaseFactory.CreateDatabase("OracleTest");
            DataSet        ds        = new DataSet();
            OracleCommand  dbCommand = (OracleCommand)db.GetStoredProcCommand("GetCustomersAndProductsView");

            db.AddParameter(dbCommand, "cur_OUT", OracleType.Cursor, 100, ParameterDirection.Output, true, 1, 1, null, DataRowVersion.Default, null);
            db.AddParameter(dbCommand, "cur_Products", OracleType.Cursor, 100, ParameterDirection.Output, true, 1, 1, null, DataRowVersion.Default, null);
            db.LoadDataSet(dbCommand, ds, new string[] { "Customers", "Products" });
            int rows    = ds.Tables["Customers"].Rows.Count;
            int columns = ds.Tables["Customers"].Columns.Count;

            Assert.IsTrue(rows == dsCustomers.Tables[0].Rows.Count);
            Assert.IsTrue(columns == dsCustomers.Tables[0].Columns.Count);
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    Assert.AreEqual(dsCustomers.Tables[0].Rows[i][j].ToString().Trim(), ds.Tables["Customers"].Rows[i][j].ToString().Trim());
                }
            }
            rows    = ds.Tables["Products"].Rows.Count;
            columns = ds.Tables["Products"].Columns.Count;
            Assert.IsTrue(rows == dsProducts.Tables[0].Rows.Count);
            Assert.IsTrue(columns == dsProducts.Tables[0].Columns.Count);
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    Assert.AreEqual(dsProducts.Tables[0].Rows[i][j].ToString().Trim(), ds.Tables["Products"].Rows[i][j].ToString().Trim());
                }
            }
        }
Example #3
0
        public void DataIsLoadedWhenLoadDataSetUsingStoredProcAndMultipleTableOverload()
        {
            OracleDatabase db = (OracleDatabase)DatabaseFactory.CreateDatabase("OracleTest");
            DataSet        ds = new DataSet();

            db.LoadDataSet("GetCustomersAndProductsView", ds, new string[] { "Customers", "Products" }, new object[] { 1, 1 });
            int rows    = ds.Tables["Customers"].Rows.Count;
            int columns = ds.Tables["Customers"].Columns.Count;

            Assert.IsTrue(rows == dsCustomers.Tables[0].Rows.Count);
            Assert.IsTrue(columns == dsCustomers.Tables[0].Columns.Count);
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    Assert.AreEqual(dsCustomers.Tables[0].Rows[i][j].ToString().Trim(), ds.Tables["Customers"].Rows[i][j].ToString().Trim());
                }
            }
            rows    = ds.Tables["Products"].Rows.Count;
            columns = ds.Tables["Products"].Columns.Count;
            Assert.IsTrue(rows == dsProducts.Tables[0].Rows.Count);
            Assert.IsTrue(columns == dsProducts.Tables[0].Columns.Count);
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    Assert.AreEqual(dsProducts.Tables[0].Rows[i][j].ToString().Trim(), ds.Tables["Products"].Rows[i][j].ToString().Trim());
                }
            }
        }