SalesOrder class has two tables as a source. Can we update properties from those two tables and save changes simultaneously? Yes, we can. Suppose we want to change OrderQty and OrderDate property.
static void Main(string[] args)
{
var o = SalesOrder.Query
.Where(Ctor.prop(typeof(SalesOrder), "SalesOrderDetailID").eq(1))
.Single() as SalesOrder;
o.OrderQty += 10;
o.OrderDate = new DateTime(2001, 07, 5);
using (ModificationsTracker mt = new ModificationsTracker(exam1sharp.Properties.Settings.Default.connString))
{
mt.Add(o);
mt.AcceptModifications();
}
}
No additional actions required to make it work. You just change object and save it. But OrderQty property stored in SalesOrderDetail table and OrderDate stored in SalesOrderHeader, and so Worm have to create script with two update statements. Furthermore don't forget about calculated fields. The task become complex. Here is the script generated by Worm.
Of course the whole batch executed in single transaction and the error in any line will rollback it.