Print Page | Close Window

DevForce duplicate my entity after save

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3880
Printed Date: 13-May-2026 at 12:56am


Topic: DevForce duplicate my entity after save
Posted By: argcargv
Subject: DevForce duplicate my entity after save
Date 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?



Replies:
Posted By: sbelini
Date 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.


Posted By: argcargv
Date 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


Posted By: sbelini
Date 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.



Print Page | Close Window