New Posts New Posts RSS Feed: ImportEntities and RelatedEntityList
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

ImportEntities and RelatedEntityList

 Post Reply Post Reply
Author
hueha View Drop Down
Newbie
Newbie


Joined: 23-Jul-2010
Posts: 38
Post Options Post Options   Quote hueha Quote  Post ReplyReply Direct Link To This Post Topic: ImportEntities and RelatedEntityList
    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);
Back to Top
hueha View Drop Down
Newbie
Newbie


Joined: 23-Jul-2010
Posts: 38
Post Options Post Options   Quote hueha Quote  Post ReplyReply Direct Link To This Post Posted: 02-Apr-2011 at 7:25am
Curious.  It will reset to IsPendingEntityList = true after you execute a query on the new entity manager

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post 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 DevForce Resource Center for detailed information about importing an entity graph.
 
Back to Top
hueha View Drop Down
Newbie
Newbie


Joined: 23-Jul-2010
Posts: 38
Post Options Post Options   Quote hueha Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down