Print Page | Close Window

ImportEntities and RelatedEntityList

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=2604
Printed Date: 21-Aug-2025 at 6:09pm


Topic: ImportEntities and RelatedEntityList
Posted By: hueha
Subject: ImportEntities and RelatedEntityList
Date Posted: 02-Apr-2011 at 7:05am
I'm not sure if I'm doing anything wrong but I've noticed that any RelatedEntityList are not being copied correctly into a sandbox entity manager.

Lets say I have a customer that has a contacts collection.  I use ImportEntities on the customer object to import it into a sandboxed entity manager.  In the sandbox the contacts collection (which is a relatedEntityList) becomes a 0 length collection with IsPendingentitylist=false.  This happens when contacts collection is loaded (not pending) or not.

This is the sort of thing I'm doing.  Where myEntities is the entity manager and myCustomer is the customer from the model. mgr is the main entity manger of type myEntities.

    var sandboxEM = new myEntities ();
            sandboxEM.LinkForAuthentication(mgr);
            sandboxEM.ImportEntities(new object[] { myCustomer}, MergeStrategy.OverwriteChanges);



Replies:
Posted By: hueha
Date Posted: 02-Apr-2011 at 7:25am
Curious.  It will reset to IsPendingEntityList = true after you execute a query on the new entity manager



Posted By: sbelini
Date Posted: 04-Apr-2011 at 9:58am
Hi hueha,
 
Thanks for pointing out the issue with IsPendingentitylist being false.
In your scenario, the contacts collection should indeed be empty. (i.e. length==0)
 
If you want the contacts to be present in the sandbox EM, you should import them as well.
 
You might want to take a look at the http://drc.ideablade.com/xwiki/bin/view/Documentation/entities-import - DevForce Resource Center for detailed information about importing an entity graph.
 


Posted By: hueha
Date Posted: 04-Apr-2011 at 5:24pm
Yeah that's what I've ended up doing.  I didn't really want to go down this path though because I'm afraid the memory footprint is going to get quite large.


Posted By: smi-mark
Date Posted: 04-Apr-2011 at 8:41pm
It won't really be that large of a footprint, as long as the EM is being disposed when the Sandbox is closed.

This is how my application looks:

Preloader EntityManager - Used on product startup to retrieve lookup tables and settings data, when an EM is created it imports data from this Preloader EM.

For each Customer edit screen a new EM is created that contains the preloaded data and then queries the data pertinent to that customer only. When the contacts edit screen is loaded a EM is created that imports from the Customer sandbox, so again, still only contains that customers info. When the contacts screen is closed, that EM is disposed of, likewise when the Customer screen is closed, that one is disposed too.

As long as you aren't loading EVERYTHING into one EM and copying it all over the place, I don't think memory use will be much of an issue.



Print Page | Close Window