Exemplo n.º 1
0
        public static void RollbackObject(this InternalEntityEntry internalEntityEntry)
        {
            IEnumerable <IProperty> properties = internalEntityEntry.EntityType.GetProperties();

            foreach (var property in properties)
            {
                PropertyEntry propertyEntry = internalEntityEntry.ToEntityEntry().Property(property.Name);
                if (propertyEntry.IsModified)
                {
                    propertyEntry.CurrentValue = propertyEntry.OriginalValue;
                    propertyEntry.IsModified   = false;
                }
            }
            internalEntityEntry.SetEntityState(EntityState.Unchanged, true);
            internalEntityEntry.AcceptChanges();
        }