public void PopulateAndUpsertExisting() { var tbl = new Rowset(Schema.GetForTypedDoc(typeof(Person))); for (var i = 0; i < 1000; i++) { tbl.Insert(new Person { ID = "POP{0}".Args(i), FirstName = "Oleg", LastName = "Popov-{0}".Args(i), DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); } var update = new Person { ID = "POP17", FirstName = "Yaroslav", LastName = "Suzkever", DOB = new DateTime(1952, 12, 10), YearsInSpace = 14 }; var res = tbl.Upsert(update);//<-------------!!!!!! Aver.IsTrue(res.Updated); var match = tbl.FindByKey("POP17") as Person; Aver.IsNotNull(match); Aver.AreEqual("Yaroslav", match.FirstName); Aver.AreEqual("Suzkever", match.LastName); }
public void LogChanges_Upsert() { var tbl = new Rowset(Schema.GetForTypedDoc(typeof(Person))); tbl.LogChanges = true; tbl.Upsert(new Person { ID = "POP1", FirstName = "Oleg", LastName = "Popov", DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); Aver.AreEqual(1, tbl.ChangeCount); Aver.IsTrue(DocChangeType.Upsert == tbl.GetChangeAt(0).Value.ChangeType); }
public void PopulateAndUpsertNonExisting() { var tbl = new Rowset(Schema.GetForTypedRow(typeof(Person))); for (var i = 0; i < 1000; i++) { tbl.Insert(new Person { ID = "POP{0}".Args(i), FirstName = "Oleg", LastName = "Popov-{0}".Args(i), DOB = new DateTime(1953, 12, 10), YearsInSpace = 12 }); } var update = new Person { ID = "GOODMAN17", FirstName = "John", LastName = "Jeffer", DOB = new DateTime(1952, 12, 10), YearsInSpace = 14 }; var existed = tbl.Upsert(update);//<-------------!!!!!! Assert.IsFalse(existed); Assert.AreEqual(1001, tbl.Count); var match = tbl.FindByKey("POP17") as Person; Assert.IsNotNull(match); Assert.AreEqual("Oleg", match.FirstName); Assert.AreEqual("Popov-17", match.LastName); match = tbl.FindByKey("GOODMAN17") as Person; Assert.IsNotNull(match); Assert.AreEqual("John", match.FirstName); Assert.AreEqual("Jeffer", match.LastName); }