public void Many_Property_Type() { TestContext.DeleteAll(x => x.Entity_Basic_Manies); TestContext.Insert(x => x.Entity_Basic_Manies, 50); using (var ctx = new TestContext()) { // BEFORE Assert.AreEqual(1225, ctx.Entity_Basic_Manies.Sum(x => x.Column1)); Assert.AreEqual(1225, ctx.Entity_Basic_Manies.Sum(x => x.Column2)); Assert.AreEqual(1225, ctx.Entity_Basic_Manies.Sum(x => x.Column3)); // ACTION var entity = new Entity_Basic_Many {Column1 = 99, Column2 = 66, Column3 = 33}; var rowsAffected = ctx.Entity_Basic_Manies.Where(x => x.Column1 > 10 && x.Column1 <= 40).Update(x => new Entity_Basic_Many { Column1 = entity.Column1, Column2 = entity.Column2, Column3 = entity.Column3 }); // AFTER Assert.AreEqual(3430, ctx.Entity_Basic_Manies.Sum(x => x.Column1)); Assert.AreEqual(2440, ctx.Entity_Basic_Manies.Sum(x => x.Column2)); Assert.AreEqual(1450, ctx.Entity_Basic_Manies.Sum(x => x.Column3)); Assert.AreEqual(30, rowsAffected); } }
public void Many_Property_Type() { TestContext.DeleteAll(x => x.Entity_Basic_Manies); TestContext.Insert(x => x.Entity_Basic_Manies, 50); using (var ctx = new TestContext()) { // BEFORE Assert.AreEqual(1225, ctx.Entity_Basic_Manies.Sum(x => x.Column1)); Assert.AreEqual(1225, ctx.Entity_Basic_Manies.Sum(x => x.Column2)); Assert.AreEqual(1225, ctx.Entity_Basic_Manies.Sum(x => x.Column3)); // ACTION var entity = new Entity_Basic_Many { Column1 = 99, Column2 = 66, Column3 = 33 }; var rowsAffected = ctx.Entity_Basic_Manies.Where(x => x.Column1 > 10 && x.Column1 <= 40).Update(x => new Entity_Basic_Many { Column1 = entity.Column1, Column2 = entity.Column2, Column3 = entity.Column3 }); // AFTER Assert.AreEqual(3430, ctx.Entity_Basic_Manies.Sum(x => x.Column1)); Assert.AreEqual(2440, ctx.Entity_Basic_Manies.Sum(x => x.Column2)); Assert.AreEqual(1450, ctx.Entity_Basic_Manies.Sum(x => x.Column3)); Assert.AreEqual(30, rowsAffected); } }