Exemplo n.º 1
0
        void DropTransctionTable()
        {
            string sql = ""
                         + "DROP TABLE Transactions ";
            var Model = new SQLServerTable <Transaction>(_connectionString);

            Model.Execute(sql);
        }
Exemplo n.º 2
0
        // UTILITY METHODS:
        void DropTransctionTable()
        {
            string sql = ""
                         + "DROP TABLE Transactions ";
            var Model = new SQLServerTable <Transaction>(CONNECTION_STRING_NAME);

            Model.Execute(sql);
        }
Exemplo n.º 3
0
        public void _Inserts_Bulk_Records()
        {
            _setup.CheckSetUp();
            int qty             = 10000;
            var newTransactions = _setup.getSkinnyTransactionSet(qty);
            var model           = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn);
            int inserted        = model.BulkInsert(newTransactions);

            Assert.True(inserted == qty);
        }
Exemplo n.º 4
0
        void CreateTransctionTable()
        {
            string sql = ""
                         + "CREATE TABLE Transactions "
                         + "(TransactionId int IDENTITY(1,1) PRIMARY KEY NOT NULL, "
                         + "Amount Money NOT NULL, "
                         + "Comment Text NOT NULL, "
                         + "Identifier Text NOT NULL)";

            var Model = new SQLServerTable <Transaction>(_connectionString);

            Model.Execute(sql);
        }
Exemplo n.º 5
0
        public void _Selects_Singles_Anonymous_Record_By_PK()
        {
            _setup.CheckSetUp();
            int qty             = 100;
            var newTransactions = _setup.getSkinnyTransactionSet(qty);
            var model           = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn);
            int inserted        = model.BulkInsert(newTransactions);

            int findRecordPk = 50;
            var newRecord    = model.Find <Transaction>(findRecordPk);

            Assert.True(newRecord != null);
        }
Exemplo n.º 6
0
        public void _Inserts_Single_Typed_Record()
        {
            _setup.CheckSetUp();
            var newRecord = new Transaction()
            {
                Amount     = 100,
                Comment    = "I Overspent!",
                Identifier = "XXX"
            };
            var model    = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn);
            var inserted = model.Insert(newRecord);

            Assert.True(newRecord.TransactionId > 0);
        }
Exemplo n.º 7
0
        public void _Inserts_Single_Anonymous_Record()
        {
            _setup.CheckSetUp();
            dynamic newRecord = new
            {
                Amount     = 100,
                Comment    = "I Anonymously Overspent!",
                Identifier = "YYZ" // Bah da-bah-bah-bah da bah-bah-bah-bah
            };
            var model    = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn);
            var inserted = model.Insert(newRecord);

            Assert.True(inserted.TransactionId > 0);
        }
Exemplo n.º 8
0
        bool TransactionTableExists()
        {
            bool   exists = false;
            string sql    = ""
                            + "SELECT * FROM INFORMATION_SCHEMA.TABLES "
                            + "WHERE TABLE_SCHEMA = 'dbo' "
                            + "AND  TABLE_NAME = 'Transactions'";
            var Model = new SQLServerTable <Transaction>(_connectionString);
            var query = Model.Query <Transaction>(sql);

            if (query.Count() > 0)
            {
                exists = true;
            }
            return(exists);
        }
Exemplo n.º 9
0
        public void _Deletes_Typed_Record()
        {
            _setup.CheckSetUp();
            var model     = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn);
            var newRecord = new Transaction()
            {
                Amount     = 100,
                Comment    = "I Overspent!",
                Identifier = "XXX"
            };

            model.Insert(newRecord);
            int recordPk = newRecord.TransactionId;

            newRecord = model.Find <Transaction>(recordPk);
            int deleted = model.Delete(newRecord.TransactionId);

            newRecord = model.Find <Transaction>(recordPk);

            Assert.True(deleted > 0 && newRecord == null);
        }
Exemplo n.º 10
0
        public void _Deletes_Anonymous_Record()
        {
            _setup.CheckSetUp();
            var model     = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn);
            var newRecord = new
            {
                Amount     = 100,
                Comment    = "I Anonymously Overspent!",
                Identifier = "YYZ" // Bah da-bah-bah-bah da bah-bah-bah-bah
            };
            //HACK - you can't interrogate the new record like you were doing...
            var result = model.Insert(newRecord);
            //WTF WHY IS THIS COMING BACK AS A DECIMAL
            var recordPk = result.TransactionId;

            // Retrieve the updated item from the Db:
            var recordToDelete = model.Find <Transaction>(recordPk);
            int deleted        = model.Delete(recordToDelete.TransactionId);

            recordToDelete = model.Find <Transaction>(recordPk);

            Assert.True(deleted > 0 && recordToDelete == null);
        }
Exemplo n.º 11
0
        public void _Updates_Typed_Record()
        {
            _setup.CheckSetUp();
            var model     = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn);
            var newRecord = new Transaction()
            {
                Amount     = 100,
                Comment    = "I Overspent!",
                Identifier = "XXX"
            };

            // Dump the new record in as an UPDATE:
            model.Insert(newRecord);
            int recordPk = newRecord.TransactionId;

            string newValue = "I changed it!";

            newRecord.Identifier = newValue;
            int updated = model.Update(newRecord);

            newRecord = model.Find <Transaction>(recordPk);

            Assert.True(updated > 0 && newRecord.Identifier == newValue);
        }
Exemplo n.º 12
0
        public void _Updates_Anonymous_Record()
        {
            _setup.CheckSetUp();
            var model     = new SQLServerTable <Transaction>(_connectionStringName, _testTableName, _tablePkColumn);
            var newRecord = new Transaction
            {
                Amount     = 100,
                Comment    = "I Anonymously Overspent!",
                Identifier = "YYZ" // Bah da-bah-bah-bah da bah-bah-bah-bah da da . . .
            };
            var result   = model.Insert(newRecord);
            int recordPk = result.TransactionId;

            var updateThis = new
            {
                Identifier = "I changed it!"
            };
            int updated = model.Update(updateThis, recordPk);

            // Retrieve the updated item from the Db:
            var updatedRecord = model.Find <Transaction>(recordPk);

            Assert.True(updated > 0 && updatedRecord.Identifier == updateThis.Identifier);
        }
Exemplo n.º 13
0
 bool TableExists(string tableName)
 {
     bool exists = false;
       string select = ""
       + "SELECT * FROM INFORMATION_SCHEMA.TABLES "
       + "WHERE TABLE_SCHEMA = 'dbo' "
       + "AND  TABLE_NAME = '{0}'";
       string sql = string.Format(select, tableName);
       var Model = new SQLServerTable<dynamic>(_connectionStringName);
       var query = Model.Query<dynamic>(sql);
       if (query.Count() > 0) {
     exists = true;
       }
       return exists;
 }
Exemplo n.º 14
0
 void DropTable(string tableName)
 {
     string sql = string.Format("DROP TABLE {0}", tableName);
       var Model = new SQLServerTable<dynamic>(_connectionStringName);
       Model.Execute(sql);
 }
Exemplo n.º 15
0
        void CreateWTFTable()
        {
            string sql = ""
              + "CREATE TABLE WTF "
              + "(Client_Id int IDENTITY(1,1) PRIMARY KEY NOT NULL, "
              + "[Last Name] Text NOT NULL, "
              + "first_name Text NOT NULL, "
              + "Email Text NOT NULL)";

              var Model = new SQLServerTable<dynamic>(_connectionStringName);
              Model.Execute(sql);
        }