New Posts New Posts RSS Feed: DevForce duplicate my entity after save
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

DevForce duplicate my entity after save

 Post Reply Post Reply
Author
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 Topic: DevForce duplicate my entity after save
    Posted: 09-Jan-2013 at 10:27am
Thanks for the description, argcargv.

I wasn't, however, able to repro it here. In the callback the Added entity is updated to Unchanged and there is no additional entity there.

If can provide a small solution showing the issue we will be able to investigate further.

sbelini.
Back to Top
argcargv View Drop Down
Newbie
Newbie
Avatar

Joined: 07-Jan-2013
Posts: 2
Post Options Post Options   Quote argcargv Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jan-2013 at 10:27pm
hi sbelini

right before calling SaveChangesAsync, I check entity manager just to make sure there is only one entity exist.
And yes, there is only one entity exist.
that entity is SalesOrder with state = Added.

after calling SaveChangesAsync (in the callback function), I recheck entity manager.
Now two entity exist (where I expect it should be only one entity exist (the one before save, but with new state = Unchanged).
basically this two entity are same. first one state is Added, and the second one is Unchange (like I told in the first post).

about PK:
PK of SalesOrder is AgencyID, and SOID.
SOID is assigned right before calling SaveChangesAsync.
AgencyID is assigned in EntityServerSaveInterceptor.

my entity before save: 
[0] AgencyID = 0, SOID = 72, state = Added

after save (in callback)
what I expect:
[0] AgencyID, 1, SOID, 72, state = Unchange
in reality:
[0] AgencyID = 0, SOID = 72, state = Added
[1] AgencyID, 1, SOID, 72, state = Unchange
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: 08-Jan-2013 at 8:23am
Hi argcargv,

The existing entity should have its EntityState/PK updated rather than a new entity being created.

Can you provide a small solution showing this odd behavior?

sbelini.
Back to Top
argcargv View Drop Down
Newbie
Newbie
Avatar

Joined: 07-Jan-2013
Posts: 2
Post Options Post Options   Quote argcargv Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jan-2013 at 8:10pm
Hi there.

I save my entity asynchronously.
right before save, there is one entity (type SalesOrder) in EntityManager with state Added.
entity key of salesorder is AgencyID and SOID.
my entity before save: AgencyID = 0, SOID = 72, state = Added

After saved, in the callback function, there are 2 SalesOrder in EntityManager.
they are look the same:
the first one AgencyID = 0, SOID = 72, state = Added
second one AgencyID, 1, SOID, 72, state = Unchange.

why after calling SaveChangesAsync, Devforce create new Entity (second) and just not replace the first one?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down