Change EntityState for Entity in Silverlight
I have an unchanged entity detached from one DomainContext and has been attached to another.
Wh开发者_运维知识库en the latter domain context submits it's changes it's trying to have the DomainService insert this unchanged entity. It's not new and it's not changed. It shouldn't be in the change set.
This enitity is around solely for displaying some of it's data. Can I change the EntityState somehow, so it doesn't try to insert?
If you use the EntitySet.Detach and EntitySet.Attach (instead of Remove/Add) methods, then it should treat the state as unchanged instead of new.
To the EntitySet, your Entity is new so it will try to insert it. I don't believe it's possible to change the state but you could always temporarily remove the Entity from the EntitySet, submit your changes and add it back.
精彩评论