New Posts New Posts RSS Feed: ImportEntities and n-n relations
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

ImportEntities and n-n relations

 Post Reply Post Reply
Author
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 Topic: ImportEntities and n-n relations
    Posted: 01-Nov-2011 at 4:51pm
I've actually just found a solution for the main issue. Now I'm just left with the same issue that Walid has. I'll post what I've had to do in my other thread.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 01-Nov-2011 at 4:35pm
Will do.

I'm not sure if they're actually the same issue though. I have to look into it again since it's been a while.
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: 31-Oct-2011 at 11:52am
This was one of the issues I was having a few months back.

http://www.ideablade.com/forum/forum_posts.asp?TID=2596&KW=smi%2Dmark&title=possible-bug-import-entities

Glad it's getting fixed. Can you update us when you know if it's going to be in the next version?
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 31-Oct-2011 at 11:46am
Hi Walid;

Sorry for the delayed reply. Yes, this is a bug and I have a filed a bug report for it. It should (but no guarantee) be fixed in the next release.


Edited by DenisK - 31-Oct-2011 at 11:48am
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 27-Oct-2011 at 1:15am
Any news Denis ?
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 19-Oct-2011 at 11:48pm
Ok, thank you Denis.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 19-Oct-2011 at 6:54pm
Hi Walid;

I was able to reproduce your issue but let me clarify this first with a senior engineer and get back to you.


Edited by DenisK - 19-Oct-2011 at 7:05pm
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 13-Oct-2011 at 2:44am
I'm trying to implement a sandbox editor for an entity having an n-n relation and have some troubles when I import the modified (and committed) entity back to the original manager.
For example, lets say we have Users (Administrator, User1, User2) and Roles (Admins, Readers,...).
A User has n-roles (User.Roles) ex User1.Roles = {Admins, Readers}, the entity relation is called UsersInRoles
After editing the existing user and removing some roles (importing it in a new EM then User1.Roles.Remove(Admins)) , re-importing it back (with a correct EntityGraph collection and OverrideChanges merge strategy) to the original EntityManager, leaves the User1.Roles collection untouched, the removed role Admins still remains in the Roles collection. If I refresh the original EM reloaded User has the correct roles.
Is it a limitation of DevForce or a bug ?
Sample Code :
...
public User ImportUser(User user, EntityManager manager)
{
...
var spans = new List<EntitySpan>() {new EntitySpan(typeof(User), EntityRelations.UsersInRoles)};
manager.ImportEntities(user.EntityAspect.EntityManager.FindEntityGraph(new object[] {user}, spans, EntityState.AllButDetached));
return = (User)manager.FindEntity(user.EntityAspect.EntityKey);
}
...
var sandboxEM = new MyEntityManager();
var sandboxUser = ImportUser(editingUser, sandboxEM);
...
sandboxUser.Roles.Remove(AdminRole);
...
sandboxEM.SaveChangesAsync(...);
...
ImportUser(sandboxUser, originalEM);
...
editingUser.Roles contains AdminRole !!!!
Thanks,
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down