Object Management strategy


I am quite new to using Aurelius and currently incorporating it into my model and would like to clarify a couple of things.

Using an object manager to extract a query result and holding that list for viewing by the client. This object manager will persist while the model is in use.

If an object on the list is changed then my understanding is that it is still managed by the object manager and will be persisted into the database by calling flush

If a new object is created and added to the object manager then it is saved in the database but the list will not reflect the additional object. The only solution I can see is to run the query again via the manager and repopulate the list so that it contains the new object. The same for deletion.

I would like to know if there is any other way to refresh the contents of the list without running the query again and also if an object is deleted using the object manager will it be removed from the list as well. Thinking about potential performance for more complex queries.

Or is a better strategy to manage the list yourself and add items to both the list and object manager at the same time (and same logic for deletion), thus persisting them to the database and managing subsequent ammendments but still keeping the object availble in memory.


The key point here is "what is list"? Do you mean a simple in-memory List<T>, or are you using a dataset so you are referring to the list of objects hold by the Aurelius Dataset?

If in-memory lists, the list itself is not managed by the object manager - just the entities it contais. So you can simply add or remove objects from the list directly, no need to perform a query again. 

Yes, you last statement describes it: the list is just yours, on manager's, do whatever you want with it. Just in case you are using the Aurelius Dataset, then it's different: you must do a dataset.Append or dataset.Delete to add/delete its objects and keep the dataset in-sync without needing to refresh it.

Wow, that was a fast response, and on a Saturday. Thanks

Yes I was looking at using a TList<T> and adding/deleting the entities from the manager.

One further question. Each time you do a Find, are the Entities  that were previously found, cleared (freed) or are they still resident in the manager? 

You're welcome ;-)

Once an entity is in the manager, it stays there no matter how many Find you execute even if that Find "returns" such entity. To be clear, not only the entity is not destroyed, but also its current state (properties) are not changed. 
If you want to destroy the entity and have manager to bring a new one, you bust first evict the entity:


Or, if you want the entity to be same instance but have its data to be refreshed from existing database data, you need to call Refresh: