New Posts New Posts RSS Feed: Create New Entity when using Multiple EntityManagers
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Create New Entity when using Multiple EntityManagers

 Post Reply Post Reply
Author
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post Topic: Create New Entity when using Multiple EntityManagers
    Posted: 09-Sep-2010 at 10:19am

We are investigating the use of multiple entity managers in our Silverlight application.

My question is if I want to create a new entity, how do I specify which entity manager to add it to when I call "AddToManager()"?
 
The EntityAspect.EntityManager property is readonly.
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: 09-Sep-2010 at 3:53pm
Hi,
 
try using .AddEntity instead:
 
myEntityManager.AddEntity(myEntity);
 
The API documentation states:
The associated EntityManager will either be the EntityManager that was called to create this Entity (M:IdeaBlade.EntityModel.EntityManager.CreateEntity``1) or that was used to generate its ids ( IdeaBlade.EntityModel.EntityManager.GenerateId) If neither of these cases apply, then the EntityManager's DefaultManager"/> will be used. There is no difference between AddToManager and M:IdeaBlade.EntityModel.EntityManager.AddEntity(IdeaBlade.EntityModel.Entity). Use either method to add a business object created by the IdeaBlade.EntityModel.EntityManager.CreateEntity method to the EntityManager cache. The object must have a "detached" IdeaBlade.EntityModel.EntityAspect.EntityState, must not have ever been associated with another EntityManager and must have a unique EntityKey within the EntityManager to which it will be added.
 
I hope it helps,
   Silvio.
Back to Top
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post Posted: 10-Sep-2010 at 4:28am
Thank you Silvio.  Your suggestion worked.  I was looking at this problem from the wrong point of view.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down