Queue for SubmitChanges and Isolated context

Aug 9, 2011 at 9:26 AM


I am looking for solution to implement some business logic in my LOB application. I've read this discussion http://riaservicescontrib.codeplex.com/discussions/243700 and I was wondering if it is possible to use Services Contrib bits to implement following solution. I need to implement something like queue for SubmitChanges with isolated context. For instance, user click Save button and continue working with entities. Out-of-box implementation of SubmitChanges switch EntitySet collection into read-only mode and it is impossible to change any entities before completion of SubmitChanges method execution. Hence, I think about following:

  1. Apply all changes in original context (I will have problem with new entities).
  2. Clone back all entities from isolated context into original (I will have problem if entities were changed in original context).

Is it possible to implement such scenario?

Thank you.



Aug 9, 2011 at 3:00 PM

Yes, the "partial save" example shows how to do that. If you have any server modified values (such as Identities or Timestamp fields) then allowing edits during the save can be a problem so watch out for that.

Aug 17, 2011 at 3:44 PM

Thank you. I am using partial save approach but I expereince some proble with child elements.

My root entity (Person) has refs to Email entity.

[global::System.ComponentModel.DataAnnotations.AssociationAttribute("Email""EmailId""Id", IsForeignKey=true)]
        public global::TFG.CompliGuard.ClearReportService.Domain.Email Email
I change some properties in Email child entity. entitySet.Where(dfp => dfp.HasChanges) returns only root element. 
Then I call
var originalState = item.ExtractState(ExtractType.OriginalState);
var modifiedState = item.ExtractState(ExtractType.ModifiedState);
Because I made changes in ref entity Email, originalState = null and after entity.ApplyState(originalState, modifiedState) entity.Email = null.
TemporaryContext.SubmitChanges() treats entity as new because originalState was null and do not save any changes to Email entity. How to extract whole entities tree for root entity?