public void InsertAnEntity() { Categories category = new Categories() { CategoryName = "Computer", Description = "Insert test" }; gooContext.Categories.Insert(category); int result = gooContext.SubmitChanges(); Assert.AreNotEqual(result, -1); }
public void OrmConfiguration() { #region LazyLoading // Varsayılan olarak false dur. // default as false. gooContext.OrmConfiguration.LazyLoadingEnabled = true; Orders order = gooContext.Orders.FirstOrDefault(); Assert.IsNotNull(order.Customer); #endregion #region Connection // 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. var connection = gooContext.OrmConfiguration.Connection; // .Open(); Assert.IsNotNull(connection); #endregion #region Transaction 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 = gooContext.Categories.FirstOrDefault(); category.Description = string.Format("{0} Updated", category.Description); gooContext.Categories.Update(category); int result = gooContext.SubmitChanges(); if (result > -1) { transaction.Commit(); } else { transaction.Rollback(); } } #endregion }