Example #1
1
        void BulkCopyTest(string context, BulkCopyType bulkCopyType)
        {
            using (var conn = new DataConnection(context))
            {
                conn.BeginTransaction();

                conn.BulkCopy(new BulkCopyOptions { MaxBatchSize = 50000, BulkCopyType = bulkCopyType },
                    Enumerable.Range(0, 100000).Select(n =>
                        new AllType
                        {
                            ID                  = 2000 + n,
                            bigintDataType      = 3000 + n,
                            smallintDataType    = (short)(4000 + n),
                            tinyintDataType     = (sbyte)(5000 + n),
                            mediumintDataType   = 6000 + n,
                            intDataType         = 7000 + n,
                            numericDataType     = 8000 + n,
                            decimalDataType     = 9000 + n,
                            doubleDataType      = 8800 + n,
                            floatDataType       = 7700 + n,
                            dateDataType        = DateTime.Now,
                            datetimeDataType    = DateTime.Now,
                            timestampDataType   = null,
                            timeDataType        = null,
                            yearDataType        = (1000 + n) % 100,
                            year2DataType       = (1000 + n) % 100,
                            year4DataType       = null,
                            charDataType        = 'A',
                            varcharDataType     = "",
                            textDataType        = "",
                            binaryDataType      = null,
                            varbinaryDataType   = null,
                            blobDataType        = new byte[] { 1, 2, 3 },
                            bitDataType         = null,
                            enumDataType        = "Green",
                            setDataType         = "one",
                            intUnsignedDataType = (uint)(5000 + n),
                        }));

                //var list = conn.GetTable<ALLTYPE>().ToList();

                conn.GetTable<DB2Test.ALLTYPE>().Delete(p => p.SMALLINTDATATYPE >= 5000);
            }
        }
Example #2
0
        public void TestTransaction2(string context)
        {
            using (var db = new DataConnection(context))
            {
                db.GetTable<Parent>().Update(p => p.ParentID == 1, p => new Parent { Value1 = 1 });

                using (var tran = db.BeginTransaction())
                {
                    db.GetTable<Parent>().Update(p => p.ParentID == 1, p => new Parent { Value1 = null });

                    Assert.IsNull(db.GetTable<Parent>().First(p => p.ParentID == 1).Value1);

                    tran.Rollback();

                    Assert.That(1, Is.EqualTo(db.GetTable<Parent>().First(p => p.ParentID == 1).Value1));
                }
            }
        }
        void BulkCopyTest(string context, BulkCopyType bulkCopyType)
        {
            using (var conn = new DataConnection(context))
            {
                conn.BeginTransaction();

                conn.BulkCopy(new BulkCopyOptions { MaxBatchSize = 50, BulkCopyType = bulkCopyType },
                    Enumerable.Range(0, 100).Select(n =>
                        new AllType
                        {
                            ID = 2000 + n,
                            bigintDataType = 3000 + n,
                            smallintDataType = (short)(4000 + n),
                            decimalDataType = 900000 + n,
                            smalldecimalDataType = 90000 + n,
                            intDataType = 7000 + n,
                            tinyintDataType = (byte)(5000 + n),
                            floatDataType = 7700 + n,
                            realDataType = 7600 + n,

                            dateDataType = DateTime.Now,
                            timeDataType = DateTime.Now - DateTime.Today,
                            seconddateDataType = DateTime.Now,
                            timestampDataType = DateTime.Now,

                            charDataType = 'A',
                            varcharDataType = "AA",
                            textDataType = "text",
                            shorttextDataType = "shorttext",
                            ncharDataType = '\u00fc',
                            nvarcharDataType = "A\u00fcfsdf\u00fc",
                            alphanumDataType = "abcQWE654",
                            binaryDataType = new byte[] { 1 },
                            varbinaryDataType = new byte[] { 1, 2, 3 },
                            blobDataType = new byte[] { 1, 2, 3, 4, 5, 6 },
                            clobDataType = "clobclobclob",
                            nclobDataType = "nclob\u00fcnclob\u00fcnclob\u00fc"
                        }));

                conn.GetTable<AllType>().Delete(p => p.ID >= 2000);
            }
        }