示例#1
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());
                }
            }
        }
        public void GuidIsPassedAsPrameterAndReturnedAsOutput()
        {
            OracleDatabase db        = (OracleDatabase)DatabaseFactory.CreateDatabase("OracleTest");
            Guid           myVal     = new Guid("33333333333333333333333333444444");
            string         spName    = "sp_GUIDTEST";
            DbCommand      dbCommand = db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "vGuidInput", DbType.Guid);
            db.SetParameterValue(dbCommand, "vGuidInput", myVal);
            db.AddParameter(dbCommand, "vGuidOutput", DbType.Guid, ParameterDirection.Output, "", DataRowVersion.Current, null);
            db.ExecuteNonQuery(dbCommand);
            Guid outputVal = (Guid)db.GetParameterValue(dbCommand, "vGuidOutput");

            Assert.IsTrue(myVal.Equals(outputVal));
        }