I am implementing a tracking system. I would like to know what objects are getting inserted or updated in the db.
I am doing that with the ContextChanges objects. However, when I insert a new object in the context and then delete it from the context, it stills appear in the GetInserts() list. If I try to manipulate it, I receive the following exception.
"It is not allowed to read or to write an instance marked for deletion."
The property "
ReadAfterDelete" wouldn't help, because if I set it to true I will believe that the object actually get inserted while it is not.
I know I could try to access a property and catch the exception to know that the object is marked for deletion, but I hope there is a better solution.
7 Answers, 1 is accepted
I don't know if this is an error or not... You still performed the "action" insert of object A in the context. And you also performed the "action" delete of object A in the context.
So if you consider the Context to be a memory registration of all the changes you performed since the creation of the context what you see is correct.
In respect to your tracking system, you should just provide that if an object is present in the "GetDeletes" lists it takes precedence over any other list.
Thank you for your reply.
What is strange is that my object does not appear in the GetDeletes() result.
@Henrik: Thank you for the valuable input.
@Christoph: As Henrik mentioned, the information provided by the GetDeletes() method is correct, since there was only a in memory operation involved in your case. But the result from the GetInserts() method is not correct and is a bug, which I would like to thank you for pointing out. Please find your Telerik points updated for this.
To your question regarding your tracking system. You can use our ITracking Interface to get notified if an object is modified. With this you can build your own logic to meet your requirements.
I hope this information is helpful for you. Feel free to ask if you have any other question.
the Telerik team
SP1 for Q3’11 of Telerik OpenAccess ORM is available for download.
thank you for the informations.
So if I understand well, neither GetInserts nor GetDeletes should give a result if an object is inserted then removed from the context without saving it.
I should be able to implement my solution now, thanks
I'm using the newer domain context.
I need to be able to turn off this behavior (disallowing reads on objects marked for deletion).
Where does one set this property "ReadAfterDelete" given one is using the domain context??
A search of Google showed the release notes for OpenAccess in 2011 Q1 making mention of adding this to the backend config/runtime settings
, but I cannot find any UI for this property in the current 2012 Q1 version.
How does one access this property?
I thought there would be a setting in the UI for the backend configuration for this, but I guess not. After playing around in the code I came across:
...which is what I was looking for, just didn't think I would need to add code for it when there is a UI.
I'm glad that you have managed to enable this feature. Nevertheless, I have added this point regarding the UI settings to our backlog.
Feel free to ask if you have any other question.
the Telerik team