public void PatchDifference_PatchDB_WithTableColumnAdded_ShouldAddColumn() { try { ITransaction transaction = TransactionFactory.CreateTransaction(); ICollection <Type> types = new List <Type>(); types.Add(typeof(ThreeColumnEntity)); TransactionFactory.DbGate.PatchDataBase(transaction, types, true); transaction.Commit(); transaction = CreateTransaction(); types = new List <Type>(); types.Add(typeof(FourColumnEntity)); TransactionFactory.DbGate.PatchDataBase(transaction, types, false); transaction.Commit(); int id = 35; transaction = CreateTransaction(); FourColumnEntity columnEntity = CreateFourColumnEntity(id); columnEntity.Persist(transaction); columnEntity = LoadFourColumnEntityWithId(transaction, id); transaction.Commit(); } catch (System.Exception e) { LogManager.GetLogger(typeof(DbGatePatchTableDifferenceDbTests)).Fatal(e.Message, e); Assert.Fail(e.Message); } }
private FourColumnEntity CreateFourColumnEntity(int id) { var entity = new FourColumnEntity(); entity.IdCol = id; entity.Code = "4C"; entity.Name = "4Col"; entity.IndexNo = 0; return(entity); }
private FourColumnEntity LoadFourColumnEntityWithId(ITransaction transaction, int id) { FourColumnEntity loadedEntity = null; IDbCommand cmd = transaction.CreateCommand(); cmd.CommandText = "select * from table_change_test_entity where id_col = ?"; IDbDataParameter parameter = cmd.CreateParameter(); cmd.Parameters.Add(parameter); parameter.DbType = DbType.Int32; parameter.Value = id; IDataReader rs = cmd.ExecuteReader(); if (rs.Read()) { loadedEntity = new FourColumnEntity(); loadedEntity.Retrieve(rs, transaction); } return(loadedEntity); }