当前位置: 首页>>代码示例>>C#>>正文


C# CUBRIDConnection.GetCollectionSize方法代码示例

本文整理汇总了C#中CUBRID.Data.CUBRIDClient.CUBRIDConnection.GetCollectionSize方法的典型用法代码示例。如果您正苦于以下问题:C# CUBRIDConnection.GetCollectionSize方法的具体用法?C# CUBRIDConnection.GetCollectionSize怎么用?C# CUBRIDConnection.GetCollectionSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUBRID.Data.CUBRIDClient.CUBRIDConnection的用法示例。


在下文中一共展示了CUBRIDConnection.GetCollectionSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_SequenceOperations

    /// <summary>
    /// Test SEQUENCE operations
    /// </summary>
    private static void Test_SequenceOperations()
    {
      using (CUBRIDConnection conn = new CUBRIDConnection())
      {
        conn.ConnectionString = TestCases.connString;
        conn.Open();

        TestCases.ExecuteSQL("DROP TABLE IF EXISTS t", conn);

        //Create a new table with a sequence

        TestCases.ExecuteSQL("CREATE TABLE t(seq SEQUENCE(int))", conn);
        //Insert some data in the sequence column
        TestCases.ExecuteSQL("INSERT INTO t(seq) VALUES({0,1,2,3,4,5,6})", conn);
        CUBRIDOid oid = new CUBRIDOid("@0|0|0");
        using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT t FROM t", conn))
        {
          using (DbDataReader reader = cmd.ExecuteReader())
          {
            while (reader.Read())
            {
              oid = (CUBRIDOid)reader[0];
            }
          }
        }

        String attributeName = "seq";
        int value = 7;

        int SeqSize = conn.GetCollectionSize(oid, attributeName);
        Debug.Assert(SeqSize == 7);

        conn.UpdateElementInSequence(oid, attributeName, 1, value);
        SeqSize = conn.GetCollectionSize(oid, attributeName);
        Debug.Assert(SeqSize == 7);

        using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn))
        {
          using (DbDataReader reader = cmd.ExecuteReader())
          {
            while (reader.Read())
            {
              int[] expected = { 7, 1, 2, 3, 4, 5, 6 };
              object[] o = (object[])reader[0];
              for (int i = 0; i < SeqSize; i++)
              {
                Debug.Assert(Convert.ToInt32(o[i]) == expected[i]);
              }
            }
          }
        }

        conn.InsertElementInSequence(oid, attributeName, 5, value);
        SeqSize = conn.GetCollectionSize(oid, attributeName);
        Debug.Assert(SeqSize == 8);

        using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn))
        {
          using (DbDataReader reader = cmd.ExecuteReader())
          {
            while (reader.Read())
            {
              int[] expected = { 7, 1, 2, 3, 7, 4, 5, 6 };
              object[] o = (object[])reader[0];
              for (int i = 0; i < SeqSize; i++)
              {
                Debug.Assert(Convert.ToInt32(o[i]) == expected[i]);
              }
            }
          }
        }

        conn.DropElementInSequence(oid, attributeName, 5);
        SeqSize = conn.GetCollectionSize(oid, attributeName);
        Debug.Assert(SeqSize == 7);

        using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn))
        {
          using (DbDataReader reader = cmd.ExecuteReader())
          {
            while (reader.Read())
            {
              int[] expected = { 7, 1, 2, 3, 4, 5, 6 };
              object[] o = (object[])reader[0];
              for (int i = 0; i < SeqSize; i++)
              {
                Debug.Assert(Convert.ToInt32(o[i]) == expected[i]);
              }
            }
          }
        }

        TestCases.ExecuteSQL("DROP t", conn);
      }
    }
开发者ID:CUBRID,项目名称:cubrid-adonet,代码行数:98,代码来源:TestDataTypes.cs

示例2: CollectionSequence_Test

        public void CollectionSequence_Test()
        {
            Log("Test GetCollectionSize, UpdateElementInSequence, InsertElementInSequence, DropElementInSequence");

            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                conn.ConnectionString = DBHelper.connString;
                conn.Open();

                DBHelper.ExecuteSQL("DROP TABLE IF EXISTS t", conn);

                //Create a new table with a sequence
                DBHelper.ExecuteSQL("CREATE TABLE t(seq SEQUENCE(int))", conn);
                //Insert some data in the sequence column
                DBHelper.ExecuteSQL("INSERT INTO t(seq) VALUES({0,1,2,3,4,5,6})", conn);
                CUBRIDOid oid = new CUBRIDOid("@0|0|0");

                LogTestStep("Test UpdateElementInSequence");
                using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT t FROM t", conn))
                {
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            oid = (CUBRIDOid)reader[0];
                        }
                    }
                }

                String attributeName = "seq";
                int SeqSize = conn.GetCollectionSize(oid, attributeName);
                Assert.AreEqual(7, SeqSize);

                conn.UpdateElementInSequence(oid, attributeName, 1, 11);
                SeqSize = conn.GetCollectionSize(oid, attributeName);
                Assert.AreEqual(7, SeqSize);

                using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn))
                {
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int[] expected = { 11, 1, 2, 3, 4, 5, 6 };
                            object[] o = (object[])reader[0];
                            for (int i = 0; i < SeqSize; i++)
                            {
                                Assert.AreEqual(expected[i], Convert.ToInt32(o[i]));
                            }
                        }
                    }
                }
                LogStepPass();

                LogTestStep("Test InsertElementInSequence");
                conn.InsertElementInSequence(oid, attributeName, 5, 12);
                SeqSize = conn.GetCollectionSize(oid, attributeName);
                Assert.AreEqual(8, SeqSize);

                using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn))
                {
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int[] expected = { 11, 1, 2, 3, 12, 4, 5, 6 };
                            object[] o = (object[])reader[0];
                            for (int i = 0; i < SeqSize; i++)
                            {
                                Assert.AreEqual(expected[i], Convert.ToInt32(o[i]));
                            }
                        }
                    }
                }

                LogStepPass();

                LogTestStep("Test DropElementInSequence");
                conn.DropElementInSequence(oid, attributeName, 6);
                SeqSize = conn.GetCollectionSize(oid, attributeName);
                Assert.AreEqual(7, SeqSize);

                using (CUBRIDCommand cmd = new CUBRIDCommand("SELECT * FROM t", conn))
                {
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int[] expected = { 11, 1, 2, 3, 12, 5, 6 };
                            object[] o = (object[])reader[0];
                            for (int i = 0; i < SeqSize; i++)
                            {
                                Assert.AreEqual(expected[i], Convert.ToInt32(o[i]));
                            }
                        }
                    }
                }
                LogStepPass();

                //revert test db
//.........这里部分代码省略.........
开发者ID:CUBRID,项目名称:cubrid-adonet,代码行数:101,代码来源:CUBRIDConnectionTest.cs


注:本文中的CUBRID.Data.CUBRIDClient.CUBRIDConnection.GetCollectionSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。