Entity collection update

Posts   
 
    
sea1731
User
Posts: 5
Joined: 29-Oct-2008
# Posted on: 20-Oct-2010 11:15:09   

Hello, I'm using Access database with LLBLGen 3 and selfservicing template. I bind the entity's collection to DevExpress grid control and make necessary changes(create,delete,update).But when I save the entity these changes are not saved. I need to save the collection with SaveMulti but it does not reflect the updates or deletes. Is there a simple way to reflect all changes done in a collection of an entity to database? thanks for the support,

Example;

Employee employee=new Employee;

//GridControl datasource - carsBindingSource carsBindingSource.DataSource = employee.GetMultiCars(true);

//Gridcontrol add,delete,change done from GUI

employee.Save(); //not save cars employee.Cars.SaveMulti();//only save newly added records, deleted records still exist

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 20-Oct-2010 11:39:24   

employee.Save(); //not save cars

To save related entities as well, you need to use gthe overload which accepts a recurse parameter.

employee.Save(true); //should save them

mployee.Cars.SaveMulti();//only save newly added records, deleted records still exist

Entities removed from a collection doesn't get deleted from the database when you save the collection. Because in other scenarioes, removing an entity doesn't necessarily mean deleting it from the persistence storage.

You should make use of: Tracking entity remove actions

sea1731
User
Posts: 5
Joined: 29-Oct-2008
# Posted on: 20-Oct-2010 12:05:50   

Thanks, it works with recurse.

I will make deletion with UnitOfWork object.