This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
My question is pretty simple. However, I was unable to get my development done with the examples provided in the help file. 1. I have a UI that calls a retrieve method. ( Find<> ). I get a strongly typed object ( Model1). I update some values of this object , example Model1.Description = " Updated Description"; 2. To save this object, my UI calls my Business Objects project and sends this updated Model1 as a parameter. My Business Object, does the following Calls the same retrieve method ( Find <> ), Gets an object Model2 and sets its value of Model1 ... Model 2 = Model 1. 3. Then I do a SaveChanges(); Instead of updating existing object, it creates a new object and adds it to the database. So, how do I update an existing object ? Also, if my object has dependency ( Lets say I have a Foreign Key on other table ), how do I update records for this kind of relationship. |
|
|
Here is how I did that: Given is a saved "Project" with association to a "Customer" and a Project may have several SubProjects:
// Edit
*** Sörnt
|
|
|
To update an existing object, modify its properties and call SaveChanges on the unit of work: using (IUnitOfWork uow = context.CreateUnitOfWork()) To update an association, just set the association property or the relevant foreign key property, i.e. either of the following: p.Manufacturer = uow.FindById<Manufacturer>(123); // setting the association Again this will be committed only when you call SaveChanges. |
|