Exemplo n.º 1
0
        public void InsertAnEntityWithTransaction()
        {
            // Connection'a erişmeniz gereken durumlarda bağlantıyı sizin açmanız gerekmektedir.
            // In case you need to reference the connection object, you need to open and manage the connection.
            gooContext.OrmConfiguration.Connection.Open();

            using (var transaction = gooContext.OrmConfiguration.Connection.BeginTransaction())
            {
                // Transaction nesnesini orm'e kullanacağımızı belirtmeliyiz.
                // You must pass in the transaction object's reference.
                gooContext.OrmConfiguration.UseTransaction(transaction);

                Categories category = new Categories()
                {
                    CategoryName = "Computer",
                    Description = "Insert test with transaction"
                };

                gooContext.Categories.Insert(category);

                int result = gooContext.SubmitChanges();

                if (result > -1)
                    transaction.Commit();
                else
                    transaction.Rollback();
            }
        }
Exemplo n.º 2
0
        public void InsertAnEntity()
        {
            Categories category = new Categories()
            {
                CategoryName = "Computer",
                Description = "Insert test"
            };

            gooContext.Categories.Insert(category);

            int result = gooContext.SubmitChanges();

            Assert.AreNotEqual(result, -1);
        }