This question is locked. New answers and comments are not allowed.
I'm wondering what the best practice is for inserting and updating persistant objects. From my UI I want to construct my object using code similar to below.
Inside my BLL I would like to do something like below and have it save my customer object and all of the child objects.
Is this possible for OA to automatically save the objects with the appropriate ID's based on the FK's? Thanks
CustomerBO cust = new CustomerBO(); |
cust.Name = "Joe"; |
cust.Orders.Add(new Order()); |
cust.Orders[0].OrderID = "12345"; |
cust.Orders.OrderDetails.Add(new OrderDetail()); |
cust.Orders[0].OrderDetails[0].PurchaseDate = Convert.ToDateTime("1/1/2010"); |
CustomerBLL bllCustomer = new CustomerBLL(); |
bllCustomer.Save(cust); |
public void Save(CustomerBO cust) |
{ |
scope.Transaction.Begin(); |
CustomerDA custDA = (CustomerDA )scope.GetObjectById(Database.OID.ParseObjectId(typeof(CustomerDA ), cust.UIDSchedule.ToString())); |
custDA.Name = cust.Name; |
scope.Add(cust); |
scope.Transaction.Commit() |
} |
Jeff