private void AutoSyncMembers(object[] syncResults, TrackedObject item, UpdateType updateType, AutoSyncBehavior autoSyncBehavior) { System.Diagnostics.Debug.Assert(item != null); System.Diagnostics.Debug.Assert(item.IsNew || item.IsPossiblyModified, "AutoSyncMembers should only be called for new and modified objects."); object[] syncRollbackValues = null; if (syncResults != null) { int idx = 0; List <MetaDataMember> membersToSync = GetAutoSyncMembers(item.Type, updateType); System.Diagnostics.Debug.Assert(syncResults.Length == membersToSync.Count); if (autoSyncBehavior == AutoSyncBehavior.ApplyNewAutoSync) { syncRollbackValues = new object[syncResults.Length]; } foreach (MetaDataMember mm in membersToSync) { object value = syncResults[idx]; object current = item.Current; MetaAccessor accessor = (mm.Member is PropertyInfo && ((PropertyInfo)mm.Member).CanWrite) ? mm.MemberAccessor : mm.StorageAccessor; if (syncRollbackValues != null) { syncRollbackValues[idx] = accessor.GetBoxedValue(current); } accessor.SetBoxedValue(ref current, DBConvert.ChangeType(value, mm.Type)); idx++; } } if (syncRollbackValues != null) { this.SyncRollbackItems.Add(new KeyValuePair <TrackedObject, object[]>(item, syncRollbackValues)); } }