Problem with ObjectNetworkAttacher

3 posts, 1 answers
  1. Alex
    Alex avatar
    27 posts
    Member since:
    Oct 2011

    Posted 04 Jun 2012 Link to this post


    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?


  2. Alex
    Alex avatar
    27 posts
    Member since:
    Oct 2011

    Posted 05 Jun 2012 Link to this post


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

  3. DevCraft banner
  4. Answer
    Ivailo avatar
    318 posts

    Posted 11 Jun 2012 Link to this post

    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,
    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!
Back to Top