Insert/Update using inherited objects

Thread is closed for posting
2 posts, 1 answers
  1. Jeff Morris
    Jeff Morris avatar
    7 posts
    Member since:
    Mar 2010

    Posted 20 Apr 2010 Link to this post

    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.
    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); 
    Inside my BLL I would like to do something like below and have it save my customer object and all of the child objects.
    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() 
    Is this possible for OA to automatically save the objects with the appropriate ID's based on the FK's?   Thanks

    Jeff
  2. Answer
    Serge
    Admin
    Serge avatar
    375 posts

    Posted 22 Apr 2010 Link to this post

    Hi Jeff Morris,

    In the case that you are using Business Objects Telerik OpenAccess ORM has no mechanism of guessing how your classes correlate to the OpenAccess classes. 

    However OpenAccess is fully capable of persisting changes in the data access objects (OpenAccess classes). This means that if you can populate your persistent classes the way you want to, including child-parent and many-to-many relationships, on Transaction.Commit() OpenAccess will save all changes in the database.

    However the responsibility of syncing the BO to the DAO lays on your shoulders. If you need further assistance, please contact us back.

    Kind regards,
    Serge
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top