Esempio n. 1
0
        private static void CrudOperationTest()
        {
            var db      = CreateDatabase();
            var deleted = db.ExecuteCommand("Delete From AllDataTypeTable");

            OutputTestResult("Query: Delete AllDataTypeTable", true);

            using (DatabaseContext dc = new DatabaseContext(CreateDatabase()))
            {
                dc.BeginTransaction(IsolationLevel.ReadCommitted);
                for (int i = 0; i < 3; i++)
                {
                    var inserted = InsertRecord(i);
                    OutputTestResult("AllDataTypeTableInsert with transaction", inserted == 1);
                }
                dc.CommitTransaction();
            }
            var t = new alldatatypetable();
            var r = t.SelectByPrimaryKey(1);

            r.PrimaryKeyColumn = 11;
            var x1 = t.Insert(r);

            OutputTestResult("AllDataTypeTable.Insert", x1 == 1);

            r = t.SelectByPrimaryKey(11);
            r.PrimaryKeyColumn = 12;
            var x2 = t.Update(r);

            OutputTestResult("AllDataTypeTable.Update", x2 == 1);

            var x3 = t.Delete(12, r.TimestampColumn);

            OutputTestResult("AllDataTypeTable.Delete", x3 == 1);
        }
Esempio n. 2
0
        private static void CrudOperationTest()
        {
            var db = CreateDatabase();
            var deleted = db.ExecuteCommand("Delete From AllDataTypeTable");
            OutputTestResult("Query: Delete AllDataTypeTable", true);

            using (DatabaseContext dc = new DatabaseContext(CreateDatabase()))
            {
                dc.BeginTransaction(IsolationLevel.ReadCommitted);
                for (int i = 0; i < 3; i++)
                {
                    var inserted = InsertRecord(i);
                    OutputTestResult("AllDataTypeTableInsert with transaction", inserted == 1);
                }
                dc.CommitTransaction();
            }
            var t = new alldatatypetable();
            var r = t.SelectByPrimaryKey(1);
            r.PrimaryKeyColumn = 11;
            var x1 = t.Insert(r);
            OutputTestResult("AllDataTypeTable.Insert", x1 == 1);

            r = t.SelectByPrimaryKey(11);
            r.PrimaryKeyColumn = 12;
            var x2 = t.Update(r);
            OutputTestResult("AllDataTypeTable.Update", x2 == 1);

            var x3 = t.Delete(12, r.TimestampColumn);
            OutputTestResult("AllDataTypeTable.Delete", x3 == 1);
        }
Esempio n. 3
0
        private static void CrudOperationTest_MySql()
        {
            var db      = DatabaseFactory.Current.CreateDatabase(DatabaseKey_MySql);
            var deleted = db.ExecuteCommand("Delete From AllDataTypeTable");

            OutputTestResult("Query: Delete AllDataTypeTable", true);

            using (TransactionContext tx = new TransactionContext(DatabaseFactory.Current.CreateDatabase(DatabaseKey_MySql)))
            {
                tx.BeginTransaction(IsolationLevel.ReadCommitted);
                for (int i = 0; i < 3; i++)
                {
                    var sp       = InsertRecord_MySql(i);
                    var inserted = sp.ExecuteNonQuery(tx);
                    OutputTestResult("AllDataTypeTableInsert with transaction", inserted == 1);
                }
                tx.CommitTransaction();
            }
            var t = new alldatatypetable();
            var r = t.SelectByPrimaryKey(1);

            r.PrimaryKeyColumn = 11;
            var x1 = t.Insert(r);

            OutputTestResult("AllDataTypeTable.Insert", x1 == 1);

            r = t.SelectByPrimaryKey(11);
            r.PrimaryKeyColumn = 12;
            var x2 = t.Update(r);

            OutputTestResult("AllDataTypeTable.Update", x2 == 1);

            var x3 = t.Delete(12, r.TimestampColumn);

            OutputTestResult("AllDataTypeTable.Delete", x3 == 1);
        }