This is a migrated thread and some comments may be shown as answers.
Problem with ObjectNetworkAttacher
2 Answers 19 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.
Alex
Top achievements
Rank 2
Alex asked on 05 Jun 2012, 03:05 AM
Hi,

I'd like to reattach an object that was serialized/deserialized using JSON.NET to the context. When I attach the object alone, all goes well but when I try to attach the object along with its related objects, it fails.

If I set the relationship to Managed, I get an exception from the AttachXML call (some index overflows), and if I set it to Unmanaged then the SaveChanges call fails on a constraint not being respected (although the id of the parent object is properly set for all my related objects).

Any idea on how to achieve this?

I know that attaching/detaching entities will be supported in the Q2 release, is it soon enough for my to wait until it is available?

Thanks,

Alexis

2 Answers, 1 is accepted

Sort by
0
Alex
Top achievements
Rank 2
answered on 05 Jun 2012, 05:01 AM
Hi,

Finally I got it to work by marking the relationship as Managed and attaching each related object in the list before attaching the parent.

Alex
0
Accepted
Ivailo
Telerik team
answered on 11 Jun 2012, 06:12 PM
Hello Alexis,

You have found the right approach as per the current version of OpenAccess ORM.

I can give you a couple of things as further details for your scenario. Attaching and Detaching of objects is currently being implemented as part of our Context API as well. In the Q2 release, already available for download on our web site, you can find the first part of this feature implemented, which includes detaching copies of existing objects and then attaching them again after making changes. More information about this stage you can find here. Unfortunately, at this stage, attaching an object that was deserialized (never been a part of the current context) is not yet possible.

In addition, we are planning to implement a second stage of the feature, which will be applicable in your scenario, allowing you to detach an entity (and related entities), send it to another tier and attach it to another context. This second stage is planned for the Service Pack, expected by the end of June.

I hope those details are useful for you. Kindly let us know if you have any other questions.

All the best,
Ivailo
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Tags
General Discussions
Asked by
Alex
Top achievements
Rank 2
Answers by
Alex
Top achievements
Rank 2
Ivailo
Telerik team
Share this question
or