public void CUBRIDCommand_Clone_Test() { using (CUBRIDConnection conn = new CUBRIDConnection(DBHelper.connString)) { conn.Open(); DBHelper.ExecuteSQL("drop table if exists t", conn); DBHelper.ExecuteSQL("create table t (id int primary key, name varchar(50))", conn); DBHelper.ExecuteSQL("insert into t (id, name) values (2, 'Rachel Green')", conn); DBHelper.ExecuteSQL("insert into t (id, name) values (3, 'Rachel Green')", conn); DBHelper.ExecuteSQL("insert into t (id, name) values (5, 'Bill Gates')", conn); LogTestStep("Clone a CUBRIDCommand which has parameters"); CUBRIDCommand cmd = new CUBRIDCommand(null, conn); cmd.CommandText = "select * from t where id = ?myId and name = ?myName"; CUBRIDParameter idParam = new CUBRIDParameter("?myId", CUBRIDDataType.CCI_U_TYPE_INT, 8); CUBRIDParameter nameParam = new CUBRIDParameter("?myName", CUBRIDDataType.CCI_U_TYPE_STRING, 20); idParam.Value = 2; nameParam.Value = "Rachel Green"; cmd.Parameters.Add(idParam); cmd.Parameters.Add(nameParam); CUBRIDCommand cmdClone = cmd.Clone(); CUBRIDDataAdapter adapter = new CUBRIDDataAdapter(); adapter.SelectCommand = cmdClone; Log("Verify the cloned command"); DataTable dt = new DataTable(""); adapter.Fill(dt); Assert.AreEqual(1, dt.Rows.Count); Assert.AreEqual(2, (int)dt.Rows[0][0]); Assert.AreEqual("Rachel Green", dt.Rows[0][1].ToString()); adapter.FillSchema(dt, SchemaType.Source);//To retrieve all the column properties you have to use the FillSchema() method Assert.AreEqual(cmdClone.ColumnInfos[0].Name, "id"); Assert.AreEqual(cmdClone.ColumnInfos[0].IsPrimaryKey, true); Assert.AreEqual(cmdClone.ColumnInfos[0].IsForeignKey, false); Assert.AreEqual(cmdClone.ColumnInfos[0].IsNullable, false); Assert.AreEqual(cmdClone.ColumnInfos[0].RealName, "t"); Assert.AreEqual(cmdClone.ColumnInfos[0].Precision, 10); Assert.AreEqual(cmdClone.ColumnInfos[0].Scale, 0); Assert.AreEqual(cmdClone.ColumnInfos[0].IsAutoIncrement, false); Assert.AreEqual(cmdClone.ColumnInfos[0].IsReverseIndex, false); Assert.AreEqual(cmdClone.ColumnInfos[0].IsReverseUnique, false); Assert.AreEqual(cmdClone.ColumnInfos[0].IsShared, false); Assert.AreEqual(cmdClone.ColumnInfos[0].Type, CUBRIDDataType.CCI_U_TYPE_INT); Assert.AreEqual(cmdClone.ColumnInfos[0].Table, "t"); LogStepPass(); adapter.Dispose(); cmd.Close(); Log("delete test db"); //DBHelper.ExecuteSQL("drop table if exists t", conn); } LogTestResult(); }