static public void Delete(System.Int64 constructorTestId, esSqlAccessType sqlAccessType) { var obj = new ConstructorTest(); obj.ConstructorTestId = constructorTestId; obj.AcceptChanges(); obj.MarkAsDeleted(); obj.Save(sqlAccessType); }
public ConstructorTestProxyStub(ConstructorTest obj, bool dirtyColumnsOnly) { theEntity = this.entity = obj; this.dirtyColumnsOnly = dirtyColumnsOnly; }
public ConstructorTestProxyStub(ConstructorTest obj) { theEntity = this.entity = obj; }
public void DefaultInConstructorIsDirtyCollection() { long id = -1; ConstructorTest entity = new ConstructorTest(); try { using (esTransactionScope scope = new esTransactionScope()) { // Create test record entity = new ConstructorTest(); entity.DefaultBool = true; entity.DefaultInt = -1; entity.DefaultDateTime = Convert.ToDateTime("2000-01-01"); entity.DefaultString = "Not new"; entity.Save(); // Get the ID of the newly saved object id = entity.ConstructorTestId.Value; // bool ConstructorTestCollection coll = new ConstructorTestCollection(); Assert.IsTrue(coll.LoadAll()); Assert.AreEqual(true, coll[0].DefaultBool.Value); Assert.AreEqual(-1, coll[0].DefaultInt.Value); Assert.AreEqual(Convert.ToDateTime("2000-01-01"), coll[0].DefaultDateTime.Value); Assert.AreEqual("Not new", coll[0].DefaultString); Assert.IsFalse(coll[0].es.IsDirty, "Load Dirty"); Assert.AreEqual(0, coll[0].es.ModifiedColumns.Count, "Load Count"); coll[0].DefaultBool = false; Assert.AreEqual(1, coll[0].es.ModifiedColumns.Count, "Bool Count"); Assert.IsTrue(coll[0].es.IsDirty, "Bool Dirty"); coll.Save(); // int coll = new ConstructorTestCollection(); Assert.IsTrue(coll.LoadAll()); Assert.AreEqual(false, coll[0].DefaultBool.Value); Assert.AreEqual(-1, coll[0].DefaultInt.Value); Assert.AreEqual(Convert.ToDateTime("2000-01-01"), coll[0].DefaultDateTime.Value); Assert.AreEqual("Not new", coll[0].DefaultString); coll[0].DefaultInt = 0; Assert.AreEqual(1, coll[0].es.ModifiedColumns.Count, "Int Count"); Assert.IsTrue(coll[0].es.IsDirty, "Int Dirty"); coll.Save(); // DateTime coll = new ConstructorTestCollection(); Assert.IsTrue(coll.LoadAll()); Assert.AreEqual(false, coll[0].DefaultBool.Value); Assert.AreEqual(0, coll[0].DefaultInt.Value); Assert.AreEqual(Convert.ToDateTime("2000-01-01"), coll[0].DefaultDateTime.Value); Assert.AreEqual("Not new", coll[0].DefaultString); coll[0].DefaultDateTime = Convert.ToDateTime("1900-01-01"); Assert.AreEqual(1, coll[0].es.ModifiedColumns.Count, "DateTime Count"); Assert.IsTrue(coll[0].es.IsDirty, "DateTime Dirty"); coll.Save(); // String coll = new ConstructorTestCollection(); Assert.IsTrue(coll.LoadAll()); Assert.AreEqual(false, coll[0].DefaultBool.Value); Assert.AreEqual(0, coll[0].DefaultInt.Value); Assert.AreEqual(Convert.ToDateTime("1900-01-01"), coll[0].DefaultDateTime.Value); Assert.AreEqual("Not new", coll[0].DefaultString); coll[0].DefaultString = "Is newer"; Assert.AreEqual(1, coll[0].es.ModifiedColumns.Count, "String Count"); Assert.IsTrue(coll[0].es.IsDirty, "String Dirty"); coll.Save(); coll = new ConstructorTestCollection(); Assert.IsTrue(coll.LoadAll()); Assert.AreEqual(false, coll[0].DefaultBool.Value); Assert.AreEqual(0, coll[0].DefaultInt.Value); Assert.AreEqual(Convert.ToDateTime("1900-01-01"), coll[0].DefaultDateTime.Value); Assert.AreEqual("Is newer", coll[0].DefaultString); // Constructor defaults coll[0].MarkAsDeleted(); coll.AddNew(); coll.Save(); coll = new ConstructorTestCollection(); Assert.IsTrue(coll.LoadAll()); Assert.IsFalse(coll.IsDirty, "Coll Constructor Dirty"); Assert.IsFalse(coll[0].es.IsDirty, "Entity Constructor Dirty"); Assert.AreEqual(0, coll[0].es.ModifiedColumns.Count); Assert.AreEqual(false, coll[0].DefaultBool.Value); Assert.AreEqual(0, coll[0].DefaultInt.Value); Assert.AreEqual(DateTime.Now.Year, coll[0].DefaultDateTime.Value.Year); Assert.AreEqual("[new]", coll[0].DefaultString); } } finally { // Clean up entity = new ConstructorTest(); if (entity.LoadByPrimaryKey(id)) { entity.MarkAsDeleted(); entity.Save(); } } }