This is a migrated thread and some comments may be shown as answers.

Insert/Update using inherited objects

1 Answer 73 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeff Morris
Top achievements
Rank 1
Jeff Morris asked on 20 Apr 2010, 09:26 PM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Serge
Telerik team
answered on 22 Apr 2010, 07:25 AM
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.
Tags
General Discussions
Asked by
Jeff Morris
Top achievements
Rank 1
Answers by
Serge
Telerik team
Share this question
or