New Posts New Posts RSS Feed: Add ability to create child entitymanager
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Add ability to create child entitymanager

 Post Reply Post Reply
Author
bigyes View Drop Down
Newbie
Newbie


Joined: 23-Sep-2010
Posts: 1
Post Options Post Options   Quote bigyes Quote  Post ReplyReply Direct Link To This Post Topic: Add ability to create child entitymanager
    Posted: 23-Sep-2010 at 10:06am
It would be great if we could create a child entitymanager from an existing entitymanager. A child would be able to see (and update) its parents already loaded entities. An entity would stay unique in a complete entitymanager hierarchy.
AcceptChanges()/RejectChanges() would only occurs on a top>down basis against this hierarchy.
 
With this, I could start a use case with its own entityManager but having already some "reference data" entities in cache.
 
I can do that using :

DXGridServerModeDBEntities _ctx = new DXGridServerModeDBEntities();

_ctx.CacheStateManager.RestoreCacheState(_refDataCtx.CacheStateManager.GetCacheState());

but "reference data" entities are duplicated.

Do you think entitymanager hierarchy is a good idea ?
 
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: 23-Sep-2010 at 12:35pm
Hi,
 
How about creating an "ChildEntityManager" and importing into it Entities from a "ParentEntityManager" by using ImportEntities(IEnumerable entities,   MergeStrategy mergeStrategy)?
Afterwards, you could import the Entities back to the ParentEntityManager with any changes that happen to be made (AcceptChanges()/RejectChanges() would only apply to the entity within one entity manager or the other).
 
You can find more details in the DevForce Resource Center.
Back to Top
jsobell View Drop Down
Groupie
Groupie
Avatar

Joined: 02-Apr-2009
Location: Australia
Posts: 80
Post Options Post Options   Quote jsobell Quote  Post ReplyReply Direct Link To This Post Posted: 23-Sep-2010 at 11:21pm
Funny you should ask for this, I was discussing exactly the same thing with Ward last week :)
I presume you're trying to implement a 'transaction' like structure so you can rollback changes to multiple child records, yet have their changes written to the parent manager when you save them.

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: 24-Sep-2010 at 12:11pm
You could probably write some sort of wrapper around the EntityManager. When you initialize it, it will load in the main entities, and upon calling the wrapped save function, it will save from the child EM, and then import back into the primary EM. Wouldn't be too difficult to write.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down