Exemple #1
0
        public void TestString(AS400DataSource ds)
        {
            using (var conn = ds.GetDataConnection(output)) {
                Assert.Equal("12345", conn.Execute <string>($"SELECT Cast('12345' as char(5)) FROM {ds.DummyTable}"));
                Assert.Equal("12345", conn.Execute <string>($"SELECT Cast('12345' as char(20)) FROM {ds.DummyTable}"));
                Assert.Null(conn.Execute <string>($"SELECT Cast(NULL    as char(20)) FROM {ds.DummyTable}"));

                Assert.Equal("12345", conn.Execute <string>($"SELECT Cast('12345' as varchar(5)) FROM {ds.DummyTable}"));
                Assert.Equal("12345", conn.Execute <string>($"SELECT Cast('12345' as varchar(20)) FROM {ds.DummyTable}"));
                Assert.Null(conn.Execute <string>($"SELECT Cast(NULL    as varchar(20)) FROM {ds.DummyTable}"));

                Assert.Equal("12345", conn.Execute <string>($"SELECT Cast('12345' as clob) FROM {ds.DummyTable}"));
                Assert.Null(conn.Execute <string>($"SELECT Cast(NULL    as clob) FROM {ds.DummyTable}"));

                var p = ds.IsOdbc ? "?" : "@p";

                Assert.Equal("123", conn.Execute <string>($"SELECT Cast({p} as char(3))     FROM {ds.DummyTable}", DataParameter.Char("p", "123")));
                Assert.Equal("123", conn.Execute <string>($"SELECT Cast({p} as varchar(3))  FROM {ds.DummyTable}", DataParameter.VarChar("p", "123")));
                Assert.Equal("123", conn.Execute <string>($"SELECT Cast({p} as char(3))     FROM {ds.DummyTable}", DataParameter.Text("p", "123")));
                Assert.Equal("123", conn.Execute <string>($"SELECT Cast({p} as nchar(3))    FROM {ds.DummyTable}", DataParameter.NChar("p", "123")));
                Assert.Equal("123", conn.Execute <string>($"SELECT Cast({p} as nvarchar(3)) FROM {ds.DummyTable}", DataParameter.NVarChar("p", "123")));
                Assert.Equal("123", conn.Execute <string>($"SELECT Cast({p} as nchar(3))    FROM {ds.DummyTable}", DataParameter.NText("p", "123")));
                Assert.Equal("123", conn.Execute <string>($"SELECT Cast({p} as char(3))     FROM {ds.DummyTable}", DataParameter.Create("p", "123")));

                Assert.Null(conn.Execute <string>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", DataParameter.Create("p", (string?)null)));
                Assert.Equal("1", conn.Execute <string>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", new DataParameter {
                    Name = "p", Value = "1"
                }));
            }
        }
Exemple #2
0
 public void TestEnum1(AS400DataSource ds)
 {
     using (var conn = ds.GetDataConnection(output)) {
         Assert.Equal(TestEnum.AA, conn.Execute <TestEnum>($"SELECT 'A' FROM {ds.DummyTable}"));
         Assert.Equal(TestEnum.AA, conn.Execute <TestEnum?>($"SELECT 'A' FROM {ds.DummyTable}"));
         Assert.Equal(TestEnum.BB, conn.Execute <TestEnum>($"SELECT 'B' FROM {ds.DummyTable}"));
         Assert.Equal(TestEnum.BB, conn.Execute <TestEnum?>($"SELECT 'B' FROM {ds.DummyTable}"));
     }
 }
Exemple #3
0
        public void TestEnum2(AS400DataSource ds)
        {
            using (var conn = ds.GetDataConnection(output)) {
                var p = ds.IsOdbc ? "?" : "@p";

                Assert.Equal("A", conn.Execute <string>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", new { p = TestEnum.AA }));
                Assert.Equal("B", conn.Execute <string>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", new { p = (TestEnum?)TestEnum.BB }));
                Assert.Equal("A", conn.Execute <string>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", new { p = ConvertTo <string> .From((TestEnum?)TestEnum.AA) }));
                Assert.Equal("A", conn.Execute <string>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", new { p = ConvertTo <string> .From(TestEnum.AA) }));
                Assert.Equal("A", conn.Execute <string>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", new { p = conn.MappingSchema.GetConverter <TestEnum?, string>() !(TestEnum.AA) }));
Exemple #4
0
 public void TestDate(AS400DataSource ds)
 {
     using (var conn = ds.GetDataConnection(output)) {
         var dateTime = new DateTime(2012, 12, 12);
         var p        = ds.IsOdbc ? "?" : "@p";
         Assert.Equal(dateTime, conn.Execute <DateTime>($"SELECT Cast('2012-12-12' as date) FROM {ds.DummyTable}"));
         Assert.Equal(dateTime, conn.Execute <DateTime?>($"SELECT Cast('2012-12-12' as date) FROM {ds.DummyTable}"));
         Assert.Equal(dateTime, conn.Execute <DateTime>($"SELECT Cast({p} as date) FROM {ds.DummyTable}", DataParameter.Date("p", dateTime)));
         Assert.Equal(dateTime, conn.Execute <DateTime?>($"SELECT Cast({p} as date) FROM {ds.DummyTable}", new DataParameter("p", dateTime, DataType.Date)));
     }
 }
Exemple #5
0
        public void TestDataTypes(AS400DataSource ds)
        {
            using (var conn = ds.GetDataConnection(output)) {
                Assert.Equal(1000000L, TestType <long?>(conn, "bigintDataType", DataType.Int64, "ALLTYPES"));
                Assert.Equal(new iDB2BigInt(1000000L), TestType <iDB2BigInt?>(conn, "bigintDataType", DataType.Int64, "ALLTYPES"));
                Assert.Equal(7777777, TestType <int?>(conn, "intDataType", DataType.Int32, "ALLTYPES"));
                Assert.Equal(new iDB2Integer(7777777), TestType <iDB2Integer?>(conn, "intDataType", DataType.Int32, "ALLTYPES"));
                Assert.Equal((short)100, TestType <short?>(conn, "smallintDataType", DataType.Int16, "ALLTYPES"));
                Assert.Equal(new iDB2SmallInt(100), TestType <iDB2SmallInt?>(conn, "smallintDataType", DataType.Int16, "ALLTYPES"));
                Assert.Equal(9999999m, TestType <decimal?>(conn, "decimalDataType", DataType.Decimal, "ALLTYPES"));
                Assert.Equal(8888888m, TestType <decimal?>(conn, "decfloatDataType", DataType.Decimal, "ALLTYPES"));
                Assert.Equal(20.31f, TestType <float?>(conn, "realDataType", DataType.Single, "ALLTYPES"));
                Assert.Equal(new iDB2Real(20.31f), TestType <iDB2Real?>(conn, "realDataType", DataType.Single, "ALLTYPES"));
                Assert.Equal(16.2d, TestType <double?>(conn, "doubleDataType", DataType.Double, "ALLTYPES"));
                Assert.Equal(new iDB2Double(16.2d), TestType <iDB2Double?>(conn, "doubleDataType", DataType.Double, "ALLTYPES"));

                Assert.Equal("1", TestType <string>(conn, "charDataType", DataType.Char, "ALLTYPES"));
                Assert.Equal("1", TestType <string>(conn, "charDataType", DataType.NChar, "ALLTYPES"));
                Assert.Equal(new iDB2Char("1"), TestType <iDB2Char?>(conn, "charDataType", DataType.Char, "ALLTYPES"));
                Assert.Equal("234", TestType <string>(conn, "varcharDataType", DataType.VarChar, "ALLTYPES"));
                Assert.Equal("234", TestType <string>(conn, "varcharDataType", DataType.NVarChar, "ALLTYPES"));
                Assert.Equal("55645", TestType <string>(conn, "clobDataType", DataType.Text, "ALLTYPES"));
                Assert.Equal("6687", TestType <string>(conn, "dbclobDataType", DataType.NText, "ALLTYPES"));

                Assert.Equal(new byte[] { 49, 50, 51, 32, 32 }, TestType <byte[]>(conn, "binaryDataType", DataType.Binary, "ALLTYPES"));
                Assert.Equal(new byte[] { 49, 50, 51, 52 }, TestType <byte[]>(conn, "varbinaryDataType", DataType.VarBinary, "ALLTYPES"));
                Assert.Equal(new byte[] { 50, 51, 52 }, TestType <byte[]>(conn, "blobDataType", DataType.Blob, "ALLTYPES", skipDefaultNull: true, skipUndefinedNull: true, skipDefault: true, skipUndefined: true));
                Assert.Equal(new byte[] { 50, 51, 52 }, TestType <byte[]>(conn, "blobDataType", DataType.VarBinary, "ALLTYPES", skipDefaultNull: true, skipUndefinedNull: true, skipDefault: true, skipUndefined: true));
                Assert.Equal("23        ", TestType <string>(conn, "graphicDataType", DataType.VarChar, "ALLTYPES"));

                Assert.Equal(new DateTime(2012, 12, 12), TestType <DateTime?>(conn, "dateDataType", DataType.Date, "ALLTYPES"));
                Assert.Equal(new iDB2Date(new DateTime(2012, 12, 12)), TestType <iDB2Date?>(conn, "dateDataType", DataType.Date, "ALLTYPES"));
                Assert.Equal(new TimeSpan(12, 12, 12), TestType <TimeSpan?>(conn, "timeDataType", DataType.Time, "ALLTYPES"));
                Assert.Equal(new iDB2Time(12, 12, 12), TestType <iDB2Time?>(conn, "timeDataType", DataType.Time, "ALLTYPES"));
                Assert.Equal(new DateTime(2012, 12, 12, 12, 12, 12, 12), TestType <DateTime?>(conn, "timestampDataType", DataType.DateTime2, "ALLTYPES"));
                Assert.Equal(new iDB2TimeStamp(new DateTime(2012, 12, 12, 12, 12, 12, 12)), TestType <iDB2TimeStamp?>(conn, "timestampDataType", DataType.DateTime2, "ALLTYPES"));

                Assert.Equal("<root><element strattr=\"strvalue\" intattr=\"12345\"/></root>", TestType <string>(conn, "xmlDataType", DataType.Xml, "ALLTYPES", skipPass: true));

                Assert.NotEmpty(conn.Execute <byte[]>($"SELECT rowid FROM AllTypes WHERE ID = 2"));
                Assert.NotEmpty(conn.Execute <iDB2Rowid>($"SELECT rowid FROM AllTypes WHERE ID = 2").Value);

                TestType <iDB2Clob>(conn, "clobDataType", DataType.Text, "ALLTYPES", skipNotNull: true);
                TestType <iDB2Blob>(conn, "blobDataType", DataType.VarBinary, "ALLTYPES", skipNotNull: true);
                TestType <iDB2Xml>(conn, "xmlDataType", DataType.Xml, "ALLTYPES", skipPass: true);

                Assert.Equal(new iDB2Decimal(9999999m).ToString(), TestType <iDB2Decimal?>(conn, "decimalDataType", DataType.Decimal, "ALLTYPES").ToString());
                Assert.Equal(new iDB2Binary(new byte[] { 49, 50, 51, 52 }).ToString(), TestType <iDB2Binary>(conn, "varbinaryDataType", DataType.VarBinary, "ALLTYPES").ToString());
                Assert.Equal(new iDB2DecFloat16(8888888m).ToString(), TestType <iDB2DecFloat16?>(conn, "decfloatDataType", DataType.Decimal, "ALLTYPES").ToString());
                Assert.Equal(new iDB2DecFloat34(8888888m).ToString(), TestType <iDB2DecFloat34?>(conn, "decfloatDataType", DataType.Decimal, "ALLTYPES").ToString());
            }
        }
Exemple #6
0
        public void TestBinary(AS400DataSource ds)
        {
            var arr1 = new byte[] { 49, 50 };
            var arr2 = new byte[] { 49, 50, 51, 52 };

            using (var conn = ds.GetDataConnection(output)) {
                Assert.Equal(arr1, conn.Execute <byte[]>($"SELECT Cast('12' as char(2) for bit data) FROM {ds.DummyTable}"));
                Assert.Equal(new Binary(arr2), conn.Execute <Binary>($"SELECT Cast('1234' as char(4) for bit data) FROM {ds.DummyTable}"));

                Assert.Equal(arr1, conn.Execute <byte[]>($"SELECT Cast('12' as varchar(2) for bit data) FROM {ds.DummyTable}"));
                Assert.Equal(new Binary(arr2), conn.Execute <Binary>($"SELECT Cast('1234' as varchar(4) for bit data) FROM {ds.DummyTable}"));
            }
        }
Exemple #7
0
        public void TestGuid(AS400DataSource ds)
        {
            using (var conn = ds.GetDataConnection(output)) {
                Assert.Equal(new Guid("6F9619FF-8B86-D011-B42D-00C04FC964FF"), conn.Execute <Guid>($"SELECT Cast('6F9619FF-8B86-D011-B42D-00C04FC964FF' as varchar(38))  FROM {ds.DummyTable}"));
                Assert.Equal(new Guid("6F9619FF-8B86-D011-B42D-00C04FC964FF"), conn.Execute <Guid?>($"SELECT Cast('6F9619FF-8B86-D011-B42D-00C04FC964FF' as varchar(38)) FROM {ds.DummyTable}"));
                var guid = Guid.NewGuid();
                var p    = ds.IsOdbc ? "?" : "@p";

                Assert.Equal(guid, conn.Execute <Guid>($"SELECT Cast({p} as char(16) for bit data) FROM {ds.DummyTable}", DataParameter.Create("p", guid)));
                Assert.Equal(guid, conn.Execute <Guid>($"SELECT Cast({p} as char(16) for bit data) FROM {ds.DummyTable}", new DataParameter {
                    Name = "p", Value = guid
                }));
            }
        }
Exemple #8
0
        public void TestTimeSpan(AS400DataSource ds)
        {
            using (var conn = ds.GetDataConnection(output)) {
                var time = new TimeSpan(12, 12, 12);
                var p    = ds.IsOdbc ? "?" : "@p";

                Assert.Equal(time, conn.Execute <TimeSpan>($"SELECT Cast('12:12:12' as time) FROM {ds.DummyTable}"));
                Assert.Equal(time, conn.Execute <TimeSpan?>($"SELECT Cast('12:12:12' as time) FROM {ds.DummyTable}"));

                Assert.Equal(time, conn.Execute <TimeSpan>($"SELECT Cast({p} as time) FROM {ds.DummyTable}", DataParameter.Time("p", time)));
                Assert.Equal(time, conn.Execute <TimeSpan>($"SELECT Cast({p} as time) FROM {ds.DummyTable}", DataParameter.Create("p", time)));
                Assert.Equal(time, conn.Execute <TimeSpan?>($"SELECT Cast({p} as time) FROM {ds.DummyTable}", new DataParameter("p", time, DataType.Time)));
                Assert.Equal(time, conn.Execute <TimeSpan?>($"SELECT Cast({p} as time) FROM {ds.DummyTable}", new DataParameter("p", time)));
            }
        }
Exemple #9
0
        public void TestNumerics(AS400DataSource ds)
        {
            var isOdbc = ds.IsOdbc;

            using (var conn = ds.GetDataConnection(output)) {
                conn.TestSimple_AS400 <sbyte>(1, DataType.SByte, isOdbc);
                conn.TestSimple_AS400 <short>(1, DataType.Int16, isOdbc);
                conn.TestSimple_AS400 <int>(1, DataType.Int32, isOdbc);
                conn.TestSimple_AS400 <long>(1L, DataType.Int64, isOdbc);
                conn.TestSimple_AS400 <byte>(1, DataType.Byte, isOdbc);
                conn.TestSimple_AS400 <ushort>(1, DataType.UInt16, isOdbc);
                conn.TestSimple_AS400 <uint>(1u, DataType.UInt32, isOdbc);
                conn.TestSimple_AS400 <ulong>(1ul, DataType.UInt64, isOdbc);
                conn.TestSimple_AS400 <float>(1, DataType.Single, isOdbc);
                conn.TestSimple_AS400 <double>(1d, DataType.Double, isOdbc);
                conn.TestSimple_AS400 <decimal>(1m, DataType.Decimal, isOdbc);
                conn.TestSimple_AS400 <decimal>(1m, DataType.VarNumeric, isOdbc);
                conn.TestSimple_AS400 <decimal>(1m, DataType.Money, isOdbc);
                conn.TestSimple_AS400 <decimal>(1m, DataType.SmallMoney, isOdbc);

                conn.TestNumeric_AS400(sbyte.MinValue, DataType.SByte, "", isOdbc);
                conn.TestNumeric_AS400(sbyte.MaxValue, DataType.SByte, "", isOdbc);
                conn.TestNumeric_AS400(short.MinValue, DataType.Int16, "", isOdbc);
                conn.TestNumeric_AS400(short.MaxValue, DataType.Int16, "", isOdbc);
                conn.TestNumeric_AS400(int.MinValue, DataType.Int32, "smallint", isOdbc);
                conn.TestNumeric_AS400(int.MaxValue, DataType.Int32, "smallint real", isOdbc);
                conn.TestNumeric_AS400(long.MinValue, DataType.Int64, "smallint int double", isOdbc);
                conn.TestNumeric_AS400(long.MaxValue, DataType.Int64, "smallint int double real", isOdbc);

                conn.TestNumeric_AS400(byte.MaxValue, DataType.Byte, "", isOdbc);
                conn.TestNumeric_AS400(ushort.MaxValue, DataType.UInt16, "smallint", isOdbc);
                conn.TestNumeric_AS400(uint.MaxValue, DataType.UInt32, "smallint int real", isOdbc);
                conn.TestNumeric_AS400(ulong.MaxValue, DataType.UInt64, "smallint int real bigint double", isOdbc);

                conn.TestNumeric_AS400(-3.40282306E+38f, DataType.Single, "bigint int smallint decimal(31) decfloat", isOdbc);
                conn.TestNumeric_AS400(3.40282306E+38f, DataType.Single, "bigint int smallint decimal(31) decfloat", isOdbc);
                conn.TestNumeric_AS400(-1.79E+308d, DataType.Double, "bigint int smallint decimal(31) decfloat real", isOdbc);
                conn.TestNumeric_AS400(1.79E+308d, DataType.Double, "bigint int smallint decimal(31) decfloat real", isOdbc);
                conn.TestNumeric_AS400(decimal.MinValue, DataType.Decimal, "bigint int smallint double real", isOdbc);
                conn.TestNumeric_AS400(decimal.MaxValue, DataType.Decimal, "bigint int smallint double real", isOdbc);
                conn.TestNumeric_AS400(decimal.MinValue, DataType.VarNumeric, "bigint int smallint double real", isOdbc);
                conn.TestNumeric_AS400(decimal.MaxValue, DataType.VarNumeric, "bigint int smallint double real", isOdbc);
                conn.TestNumeric_AS400(-922337203685477m, DataType.Money, "int smallint real", isOdbc);
                conn.TestNumeric_AS400(+922337203685477m, DataType.Money, "int smallint real", isOdbc);
                conn.TestNumeric_AS400(-214748m, DataType.SmallMoney, "smallint", isOdbc);
                conn.TestNumeric_AS400(+214748m, DataType.SmallMoney, "smallint", isOdbc);
            }
        }
Exemple #10
0
        public void TestXml(AS400DataSource ds)
        {
            using (var conn = ds.GetDataConnection(output)) {
                Assert.Equal("<xml/>", conn.Execute <string>($"SELECT Cast('<xml/>' as char(10)) FROM {ds.DummyTable}"));
                Assert.Equal("<xml />", conn.Execute <XDocument>($"SELECT Cast('<xml/>' as char(10)) FROM {ds.DummyTable}").ToString());
                Assert.Equal("<xml />", conn.Execute <XmlDocument>($"SELECT Cast('<xml/>' as char(10)) FROM {ds.DummyTable}").InnerXml);

                var xdoc = XDocument.Parse("<xml/>");
                var xml  = Convert <string, XmlDocument> .Lambda("<xml/>");

                var p = ds.IsOdbc ? "?" : "@p";

                Assert.Equal("<xml/>", conn.Execute <string>($"SELECT Cast({p} as char(10)) FROM {ds.DummyTable}", DataParameter.Xml("p", "<xml/>")));
                Assert.Equal("<xml />", conn.Execute <XDocument>($"SELECT Cast({p} as char(10)) FROM {ds.DummyTable}", DataParameter.Xml("p", xdoc)).ToString());
                Assert.Equal("<xml />", conn.Execute <XmlDocument>($"SELECT Cast({p} as char(10)) FROM {ds.DummyTable}", DataParameter.Xml("p", xml)).InnerXml);
                Assert.Equal("<xml />", conn.Execute <XDocument>($"SELECT Cast({p} as char(10)) FROM {ds.DummyTable}", new DataParameter("p", xdoc)).ToString());
                Assert.Equal("<xml />", conn.Execute <XDocument>($"SELECT Cast({p} as char(10)) FROM {ds.DummyTable}", new DataParameter("p", xml)).ToString());
            }
        }
Exemple #11
0
        public void TestParameters(AS400DataSource ds)
        {
            using (var conn = ds.GetDataConnection(output)) {
                var dsInfo = ((DbConnection)conn.Connection).GetSchemaHelper().DataSourceInformationRow();
                var p      = dsInfo.ParameterName("p");
                var p1     = dsInfo.ParameterName("p1");
                var p2     = dsInfo.ParameterName("p2");

                Assert.Equal("1", conn.Execute <string>($"SELECT Cast({p} as int)  FROM {ds.DummyTable}", new { p = 1 }));
                Assert.Equal("1", conn.Execute <string>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", new { p = "1" }));
                Assert.Equal(1, conn.Execute <int>($"SELECT Cast({p} as int)  FROM {ds.DummyTable}", new { p = new DataParameter {
                                                                                                               Value = 1
                                                                                                           } }));
                Assert.Equal("1", conn.Execute <string>($"SELECT Cast({p1} as char) FROM {ds.DummyTable}", new { p1 = new DataParameter {
                                                                                                                     Value = "1"
                                                                                                                 } }));
                Assert.Equal(5, conn.Execute <int>($"SELECT Cast({p1} as int) + Cast({p2} as int) FROM {ds.DummyTable}", new { p1 = 2, p2 = 3 }));
                Assert.Equal(5, conn.Execute <int>($"SELECT Cast({p2} as int) + Cast({p1} as int) FROM {ds.DummyTable}", new { p2 = 2, p1 = 3 }));
            }
        }
Exemple #12
0
        public void TestChar(AS400DataSource ds)
        {
            using (var conn = ds.GetDataConnection(output)) {
                Assert.Equal('1', conn.Execute <char>($"SELECT Cast('1' as char) FROM {ds.DummyTable}"));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast('1' as char) FROM {ds.DummyTable}"));
                Assert.Equal('1', conn.Execute <char>($"SELECT Cast('1' as char(1)) FROM {ds.DummyTable}"));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast('1' as char(1)) FROM {ds.DummyTable}"));

                Assert.Equal('1', conn.Execute <char>($"SELECT Cast('1' as varchar(1)) FROM {ds.DummyTable}"));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast('1' as varchar(1)) FROM {ds.DummyTable}"));
                Assert.Equal('1', conn.Execute <char>($"SELECT Cast('1' as varchar(20)) FROM {ds.DummyTable}"));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast('1' as varchar(20)) FROM {ds.DummyTable}"));

                var p = ds.IsOdbc ? "?" : "@p";
                // [IBM][DB2/LINUXX8664] SQL0418N  The statement was not processed because the statement contains an invalid use of one of the following: an untyped parameter marker, the DEFAULT keyword, or a null value.
                //Assert.Equal('1', conn.Execute<char> ($"SELECT {p} FROM {ds.DummyTable}",                  DataParameter.Char("p", '1')));
                //Assert.Equal('1', conn.Execute<char?>($"SELECT {p} FROM {ds.DummyTable}",                  DataParameter.Char("p", '1')));
                Assert.Equal('1', conn.Execute <char>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", DataParameter.Char("p", '1')));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", DataParameter.Char("p", '1')));
                Assert.Equal('1', conn.Execute <char>($"SELECT Cast({p} as char(1)) FROM {ds.DummyTable}", DataParameter.Char("p", '1')));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast({p} as char(1)) FROM {ds.DummyTable}", DataParameter.Char("p", '1')));

                Assert.Equal('1', conn.Execute <char>($"SELECT Cast({p} as varchar) FROM {ds.DummyTable}", DataParameter.VarChar("p", '1')));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast({p} as varchar) FROM {ds.DummyTable}", DataParameter.VarChar("p", '1')));
                Assert.Equal('1', conn.Execute <char>($"SELECT Cast({p} as nchar) FROM {ds.DummyTable}", DataParameter.NChar("p", '1')));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast({p} as nchar) FROM {ds.DummyTable}", DataParameter.NChar("p", '1')));
                Assert.Equal('1', conn.Execute <char>($"SELECT Cast({p} as nvarchar) FROM {ds.DummyTable}", DataParameter.NVarChar("p", '1')));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast({p} as nvarchar) FROM {ds.DummyTable}", DataParameter.NVarChar("p", '1')));
                Assert.Equal('1', conn.Execute <char>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", DataParameter.Create("p", '1')));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", DataParameter.Create("p", '1')));

                Assert.Equal('1', conn.Execute <char>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", new DataParameter {
                    Name = "p", Value = '1'
                }));
                Assert.Equal('1', conn.Execute <char?>($"SELECT Cast({p} as char) FROM {ds.DummyTable}", new DataParameter {
                    Name = "p", Value = '1'
                }));
            }
        }
Exemple #13
0
 public void TestConnectionString(AS400DataSource dataSource) => Assert.True(dataSource.ConnectionString != null, dataSource.ConnectionString);