Exemplo n.º 1
0
        public void ExecuteObject3()
        {
            using (DbManager db = new DbManager())
            {
                DataTypeTest2 dt = (DataTypeTest2)db
                                   .SetCommand("SELECT * FROM DataTypeTest WHERE DataTypeID = " + db.DataProvider.Convert("id", ConvertType.NameToQueryParameter),
                                               db.Parameter("id", 2))
                                   .ExecuteObject(typeof(DataTypeTest2));

                TypeAccessor.WriteConsole(dt);
                Console.WriteLine(dt.XmlDoc_.InnerXml);
            }
        }
Exemplo n.º 2
0
        public void TestDataTypeTestInsertWithIdentity()
        {
            using (DbManager db = new DbManager())
            {
                var dt = new DataTypeTest2
                {
                    Binary_ = new byte[2] {
                        1, 2
                    },
#if !ORACLE
                    Boolean_ = true,
                    Guid_    = Guid.Empty,
#endif
                    Byte_     = 250,
                    Bytes_    = new byte[] { 2, 1 },
                    DateTime_ = DateTime.Now,
                    Decimal_  = 9876543210.0m,
                    Double_   = 12345.67890,
                    Int16_    = 12345,
                    Int32_    = 1234567890,
                    Int64_    = 1234567890123456789,
                    Money_    = 99876543210.0m,
                    Single_   = 1234.0f,
                    String_   = "Crazy Frog",

                    Char_   = 'F',
                    SByte_  = 123,
                    UInt16_ = UInt16.MaxValue,
                    UInt32_ = UInt32.MaxValue,
                    UInt64_ = UInt64.MaxValue,
#if !SQLCE
                    Stream_ = new MemoryStream(5),
                    Xml_    = new XmlTextReader(new StringReader("<xml/>")),
                    XmlDoc_ = new XmlDocument()
#endif
                };

#if !SQLCE
                string innerxml = "<root><sql id=\"2\">Other Verbiage</sql></root>";
                dt.XmlDoc_.LoadXml(innerxml);
#endif

                var id  = Convert.ToInt32(db.InsertWithIdentity(dt));
                var obj = db.GetTable <DataTypeTest2>().Where(_ => _.ID == id).First();

#if !SQLCE
                Assert.AreEqual(innerxml, obj.XmlDoc_.OuterXml);
#endif
                TypeAccessor.WriteConsole(obj);
            }
        }
Exemplo n.º 3
0
        public void TestDataTypeTestInsert()
        {
            using (DbManager db = new DbManager())
            {
                var dt = new DataTypeTest2
                {
                    Binary_ = new byte[2] {
                        1, 2
                    },
#if !ORACLE
                    Boolean_ = true,
                    Guid_    = Guid.Empty,
#endif
                    Byte_     = 250,
                    Bytes_    = new byte[] { 2, 1 },
                    DateTime_ = DateTime.Now,
                    Decimal_  = 9876543210.0m,
                    Double_   = 12345.67890,
                    Int16_    = 12345,
                    Int32_    = 1234567890,
                    Int64_    = 1234567890123456789,
                    Money_    = 99876543210.0m,
                    Single_   = 1234.0f,
                    String_   = "Crazy Frog",

                    Char_   = 'F',
                    SByte_  = 123,
                    UInt16_ = UInt16.MaxValue,
                    UInt32_ = UInt32.MaxValue,
                    UInt64_ = UInt64.MaxValue,
#if !SQLCE
                    Stream_ = new MemoryStream(5),
                    Xml_    = new XmlTextReader(new StringReader("<xml/>")),
                    XmlDoc_ = new XmlDocument()
#endif
                };

#if !SQLCE
                dt.XmlDoc_.LoadXml("<root><sql id=\"1\">Some Text</sql></root>");
#endif

                SqlQuery query = new SqlQuery(db);
                query.Insert(dt);
                var list = query.SelectAll <DataTypeTest2>();
                Assert.That(list.Any(_ => _.UInt16_ == UInt16.MaxValue && _.UInt32_ == UInt32.MaxValue && _.UInt64_ == UInt64.MaxValue));
            }
        }
Exemplo n.º 4
0
        public void NullableTest3(Func <DbManager, DataTypeTest2, int> insert, string config)
        {
            using (var db = new TestDbManager(config))
            {
                var data = new DataTypeTest2()
                {
                    Byte_    = 0,
                    Int16_   = 0,
                    Int32_   = 0,
                    Int64_   = 0,
                    UInt16_  = 0,
                    UInt32_  = 0,
                    UInt64_  = 0,
                    Decimal_ = 0,
                    Double_  = 0,
                    Money_   = 0,
                    Single_  = 0,
                    SByte_   = 0,
                };

                var id = insert(db, data);

                var list = db.GetTable <DataTypeTest>().Where(_ => _.DataTypeID >= id).ToList();
                var i    = 0;
                foreach (var d2 in list)
                {
                    Console.WriteLine("Iteration: " + i++);
                    Assert.IsNull(d2.Byte_);
                    Assert.IsNull(d2.Decimal_);
                    Assert.IsNull(d2.Double_);
                    Assert.IsNull(d2.Int16_);
                    Assert.IsNull(d2.Int32_);
                    Assert.IsNull(d2.Int64_);
                    Assert.IsNull(d2.Money_);
                    Assert.IsNull(d2.Single_);

                    Assert.IsNull(d2.SByte_);
                    Assert.IsNull(d2.UInt16_);
                    Assert.IsNull(d2.UInt32_);
                    Assert.IsNull(d2.UInt64_);
                }
                db.GetTable <SmallDataTypeTest>().Delete(_ => _.DataTypeID > 2);
            }
        }
Exemplo n.º 5
0
		public void TestDataTypeTestInsertWithIdentity()
		{
			using (DbManager db = new DbManager())
			{
				var dt = new DataTypeTest2
				{
					Binary_ = new byte[2] { 1, 2 },
#if !ORACLE
					Boolean_ = true,
					Guid_ = Guid.Empty,
#endif
					Byte_ = 250,
					Bytes_ = new byte[] { 2, 1 },
					DateTime_ = DateTime.Now,
					Decimal_ = 9876543210.0m,
					Double_ = 12345.67890,
					Int16_ = 12345,
					Int32_ = 1234567890,
					Int64_ = 1234567890123456789,
					Money_ = 99876543210.0m,
					Single_ = 1234.0f,
					String_ = "Crazy Frog",

					Char_ = 'F',
					SByte_ = 123,
					//UInt16_   = 65432,
					//UInt32_   = 4000000000,
					//UInt64_   = 12345678901234567890,
#if !SQLCE
					Stream_ = new MemoryStream(5),
					Xml_ = new XmlTextReader(new StringReader("<xml/>")),
					XmlDoc_ = new XmlDocument()
#endif
				};

#if !SQLCE
				string innerxml = "<root><sql id=\"2\">Other Verbiage</sql></root>";
				dt.XmlDoc_.LoadXml(innerxml);
#endif

				var id = Convert.ToInt32(db.InsertWithIdentity(dt));
				var obj = db.GetTable<DataTypeTest2>().Where(_ => _.ID == id).First();

#if !SQLCE
				Assert.AreEqual(innerxml, obj.XmlDoc_.OuterXml);
#endif
				TypeAccessor.WriteConsole(obj);
			}
		}
Exemplo n.º 6
0
		public void TestDataTypeTestInsert()
		{
			using (DbManager db = new DbManager())
			{
				var dt = new DataTypeTest2
				{
					Binary_ = new byte[2] { 1, 2 },
#if !ORACLE
					Boolean_ = true,
					Guid_ = Guid.Empty,
#endif
					Byte_ = 250,
					Bytes_ = new byte[] { 2, 1 },
					DateTime_ = DateTime.Now,
					Decimal_ = 9876543210.0m,
					Double_ = 12345.67890,
					Int16_ = 12345,
					Int32_ = 1234567890,
					Int64_ = 1234567890123456789,
					Money_ = 99876543210.0m,
					Single_ = 1234.0f,
					String_ = "Crazy Frog",

					Char_ = 'F',
					SByte_ = 123,
					//UInt16_   = 65432,
					//UInt32_   = 4000000000,
					//UInt64_   = 12345678901234567890,
#if !SQLCE
					Stream_ = new MemoryStream(5),
					Xml_ = new XmlTextReader(new StringReader("<xml/>")),
					XmlDoc_ = new XmlDocument()
#endif
				};

#if !SQLCE
				dt.XmlDoc_.LoadXml("<root><sql id=\"1\">Some Text</sql></root>");
#endif

				SqlQuery query = new SqlQuery(db);
				query.Insert(dt);
			}
		}