コード例 #1
0
ファイル: ClientTests.cs プロジェクト: koralium/Koralium
        public void TestExecuteScalarCount()
        {
            KoraliumConnectionStringBuilder builder = new KoraliumConnectionStringBuilder();

            builder.DataSource = webFactory.GetUrl();

            KoraliumConnection connection = new KoraliumConnection();

            connection.ConnectionString = builder.ConnectionString;
            connection.Open();

            var cmd = connection.CreateCommand();

            cmd.CommandText = "select count(*) from project";
            var value = cmd.ExecuteScalar();

            Assert.AreEqual(2, value);
        }
コード例 #2
0
        public void TestDecimalValueGetDataTypeName()
        {
            KoraliumConnectionStringBuilder builder = new KoraliumConnectionStringBuilder();

            builder.DataSource = webFactory.GetUrl();

            KoraliumConnection connection = new KoraliumConnection();

            connection.ConnectionString = builder.ConnectionString;
            connection.Open();

            var cmd = connection.CreateCommand();

            cmd.CommandText = "select decimalvalue from typetest";

            var reader = cmd.ExecuteReader();

            string actual = reader.GetDataTypeName(0);

            Assert.AreEqual("decimal", actual);
        }
コード例 #3
0
        public void TestGetDecimalValueGetValue()
        {
            KoraliumConnectionStringBuilder builder = new KoraliumConnectionStringBuilder();

            builder.DataSource = webFactory.GetUrl();

            KoraliumConnection connection = new KoraliumConnection();

            connection.ConnectionString = builder.ConnectionString;
            connection.Open();

            var cmd = connection.CreateCommand();

            cmd.CommandText = "select decimalvalue from typetest";

            var reader = cmd.ExecuteReader();

            var decimalordinal = reader.GetOrdinal("decimalvalue");

            List <object> actual = new List <object>();

            while (reader.Read())
            {
                var val = reader.GetValue(decimalordinal);
                actual.Add(val);
            }

            List <decimal> expected = new List <decimal>
            {
                1,
                3,
                17,
                1,
                3
            };

            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
ファイル: ClientTests.cs プロジェクト: koralium/Koralium
        public void TestSelectString()
        {
            KoraliumConnectionStringBuilder builder = new KoraliumConnectionStringBuilder();

            builder.DataSource = webFactory.GetUrl();

            KoraliumConnection connection = new KoraliumConnection();

            connection.ConnectionString = builder.ConnectionString;
            connection.Open();

            var cmd = connection.CreateCommand();

            cmd.CommandText = "select * from project";

            var reader = cmd.ExecuteReader();

            var companyOrdinal = reader.GetOrdinal("company");

            while (reader.Read())
            {
                var company = reader.GetFieldValue <Company>(companyOrdinal);
            }
        }