Print Page | Close Window

Reference lists in sandboxed entity manager

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2463
Printed Date: 06-May-2025 at 11:59pm


Topic: Reference lists in sandboxed entity manager
Posted By: hueha
Subject: Reference lists in sandboxed entity manager
Date Posted: 23-Jan-2011 at 3:03am
I'm trying to sandbox my editing but I'm across a problem.  If I try and assign an entity to the property of another entity I get the following error

Cannot assign entities from one entity manager to another unless the entity on one side or the other is detached.

I've managed to get around it for some static reference data by assigning it via primary keys rather than the related object.  But how should this work for many to many relationships.  

Another scenario.
Lets say I have a parent child relation e.g. "invoice" and "invoice detail" and invoice detail have an"item" property.  If I sandboxed the invoice edit and then sandboxed the invoice detail edit would I end up with 3 versions of the "item" entity (1 in the main EM, one in the invoice sandbox and one in the invoice detail sandbox) in memory, is there a better way to handle this?  

Or is the recommended way to sandbox the invoice from the main em and the invoice detail from the main em also instead of importing from the invoice sandbox, which would avoid the need for the invoice sandbox to contain the items for the invoice detail sandbox.  If this is the better way how to I reflect the changes from the invoice detail sandbox in the invoice when the invoice detail sandbox closes.





Replies:
Posted By: smi-mark
Date Posted: 23-Jan-2011 at 11:13am
You have to import any entities you want to use into the new entity manager.

Rather than sandboxing Invoices and Invoice Details individually, I would sandbox the entire Invoice/Invoice Detail area. So that if you have multiple invoices open, they are in different managers, but each invoice and it's child details are together.







Print Page | Close Window