0

Is there a way in telerik openaccess to copy an object from one OpenAccessContext to another?

I tried the following (ugly) approach: Take an object of one context, serialize it, deserialize and then put it in another context.

I cannot believe that there is no build in method to just clone an object. Does anyone know a better way? (and i do not mean: copy using reflection)

Offler
  • 1,223
  • 1
  • 12
  • 34

2 Answers2

1

You could use the Attach / Detach functionality of OpenAccess ORM to handle this scenario.

Damyan Bogoev
  • 688
  • 4
  • 12
  • Functionality seems to be neither available in ObjectScope or IExtendedObjectScope? – Offler Oct 31 '12 at 11:27
  • You could use the scope methods: AttachCopies / CreateDetachedCopies. – Damyan Bogoev Oct 31 '12 at 17:36
  • You could contact the OpenAccess ORM support, in order to help you resolving the wrong behavior. http://www.telerik.com/community/forums/orm.aspx – Damyan Bogoev Jan 24 '13 at 07:05
  • Oh sorry, was a bit short: I tried the openaccess forum multiple times. The offered 2 solutions, which did not help at all (different error messages, mostly problems with linked objects, - only worked here for non linked objects...). In november we gave up using the build in things of OA. Now we use a generic object with a create method which recursivly creates a copy of an object in another objectscope, inherited from this object (~200 classes with sligh adjustments for linked objects) and this solution seems to work. Sadly the build in things were a waste of time for the project. – Offler Jan 24 '13 at 07:37
0

Have you used the old ObjectContainer approach, available in the Classic API or the latest OpenAccessContext.CreateDetachedCopy + OpenAccessContext.AttachCopy functionality? I am wondering which one has caused the troubles

Ivailo
  • 31
  • 2