Beispiel #1
0
 public void SyncObjectsStatePostCommit()
 {
     foreach (var dbEntityEntry in ChangeTracker.Entries())
     {
         ((IObjectState)dbEntityEntry.Entity).ObjectState = StateHelper.ConvertState(dbEntityEntry.State);
     }
 }
Beispiel #2
0
 private void SyncObjectsStatePreCommit()
 {
     foreach (var dbEntityEntry in ChangeTracker.Entries())
     {
         dbEntityEntry.State = StateHelper.ConvertState(((IObjectState)dbEntityEntry.Entity).ObjectState);
     }
 }
        /********************************************************************************
        **                                                                             **
        **        THIS METHOD HAS BEEN MODIFIED AND REQUIRES FURTHER TESTING!          **
        **                                                                             **
        ********************************************************************************/

        // Original URF library code
        //
        // private void SyncObjectsStatePreCommit()
        // {
        //     foreach (var dbEntityEntry in ChangeTracker.Entries())
        //     {
        //         dbEntityEntry.State =
        //             StateHelper.ConvertState(
        //                 ((IObjectState) dbEntityEntry.Entity).ObjectState);
        //     }
        // }

        private void SyncObjectsStatePreCommit()
        {
            // The body of the following foreach() loop originally simply assigned the
            // urfEntityState to the dbEntityEntry.State.  Unfortunately, this approach
            // failed with Identity 2.0 managed entities.
            //
            // Microsoft's Identity 2.0 framework knows nothing about the URF's
            // IObject state and works directly with the DbEntityEntry state so the URF
            // is unaware of any changes made to entities managed by Identity 2.0.
            foreach (var dbEntityEntry in ChangeTracker.Entries())
            {
                var objectState    = ((IObjectState)dbEntityEntry.Entity).ObjectState;
                var urfEntityState = StateHelper.ConvertState(objectState);
                var entityState    = dbEntityEntry.State;

                // The URF ObjectState, if set, always wins
                // This logic needs testing in a wider variety of applications
                if ((urfEntityState != EntityState.Unchanged) &&
                    (entityState == EntityState.Unchanged))
                {
                    dbEntityEntry.State = urfEntityState;
                }
                else if (urfEntityState != entityState)
                {
                    ((IObjectState)dbEntityEntry.Entity).ObjectState =
                        StateHelper.ConvertState(entityState);
                }
            }
        }
Beispiel #4
0
 public void SyncObjectsStatePostCommit()
 {
     foreach (var dbEntityEntry in ChangeTracker.Entries())
     {
         //Noha Changes : Adding the following to check to support backward compatibility as the framework expects an explicit setting for Object state so by adding the new state NotSet and the check below to depend on the default entity framework state
         if (((IObjectState)dbEntityEntry.Entity).ObjectState != ObjectState.NotSet)
         {
             ((IObjectState)dbEntityEntry.Entity).ObjectState = StateHelper.ConvertState(dbEntityEntry.State);
         }
     }
 }
Beispiel #5
0
 public void SyncObjectState <TEntity>(TEntity entity) where TEntity : class, IObjectState
 {
     Entry(entity).State = StateHelper.ConvertState(entity.ObjectState);
 }
Beispiel #6
0
 public void SyncObjectState(object entity)
 {
     Entry(entity).State = StateHelper.ConvertState(((IObjectState)entity).ObjectState);
 }