This is a migrated thread and some comments may be shown as answers.
Test if an object is marked for deletion
7 Answers 61 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christoph
Top achievements
Rank 1
Christoph asked on 19 Jan 2012, 09:58 AM
Hello

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.

Thank you

7 Answers, 1 is accepted

Sort by
0
IT-Als
Top achievements
Rank 1
answered on 19 Jan 2012, 11:20 AM
Hi Christoph,

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.

Regards

Henrik
0
Christoph
Top achievements
Rank 1
answered on 19 Jan 2012, 12:45 PM
Hello Henrik

Thank you for your reply.

What is strange is that my object does not appear in the GetDeletes() result.
0
Accepted
Ralph Waldenmaier
Telerik team
answered on 19 Jan 2012, 03:29 PM
Hi Christoph,
@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.

All the best,
Ralph
the Telerik team

SP1 for Q3’11 of Telerik OpenAccess ORM is available for download

0
Christoph
Top achievements
Rank 1
answered on 19 Jan 2012, 04:05 PM
Hello Ralph

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
Regards
0
Shawn Krivjansky
Top achievements
Rank 1
answered on 13 Apr 2012, 09:14 PM
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
http://www.telerik.com/products/orm/whats-new/release-history/q1-2011-sp1-version-2011-1-411.aspx
, but I cannot find any UI for this property in the current 2012 Q1 version.

How does one access this property?
0
Shawn Krivjansky
Top achievements
Rank 1
answered on 13 Apr 2012, 09:43 PM
Nevermind.
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:

backend.Runtime.AllowReadAfterDelete

...which is what I was looking for, just didn't think I would need to add code for it when there is a UI.

 

0
Ralph Waldenmaier
Telerik team
answered on 16 Apr 2012, 11:08 AM
Hi Shawn Krivjansky,

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.

All the best,
Ralph
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Tags
General Discussions
Asked by
Christoph
Top achievements
Rank 1
Answers by
IT-Als
Top achievements
Rank 1
Christoph
Top achievements
Rank 1
Ralph Waldenmaier
Telerik team
Shawn Krivjansky
Top achievements
Rank 1
Share this question
or