Hi
Is there any way of deleting object from TObjectManager but not from database?
Fallowing scenario
TEntry = class
Item: TItem;
// other very usefull stuff
end
TEntryList = TObjectList<TEntry>;
Entry[0].Item := Manager.Find<TItem>(1);
Entry[1].Item := Manager.Find<TItem>(2);
Its all displayed in grid, user changes details of it etc.
Then I usually use Manager.Flush to save all objectcts at one, perfect! But I want to add functionality where user just deletes one item from the list
EntryList.Remove(CurrentEntry);
Works fine until this moment but problem arise when we trying to save.
Manager.Remove(Item);
Removes object from the database (not what I want)
I can't leave them in Manager.ObjectList because I don't want to save any prior changes made for this objects, so if changes were made Manager.Flush will force it to be saved.
Ideal scenario would be something like
Manager.DeleteObject(Item);
Which just destoy object and removes reference from object list but not from database, like if would never existsed.
Appriciate any help!
Regards,
Arthur
Currently this is not possible. We are considering adding a method to do that (remove an object from the manager). But you can do something similar now by setting Manager.OwnsObjects := false then destroying the manager after retrieving objects. This way you can work with the objects as you want, then when you want to save them, you can create a new manager and then just Merge/Save the objects again.