private void RevertCollectionChange <T>(IEnumerable entities)
            where T : class, IDbEntity
        {
            ICollection <T> collection = entities as ICollection <T>;

            if (Before == null && After != null && DbEntityUtilities.IsIDbEntity(After.GetType()))
            {
                // This property change refers to a newly added entity to this collection. To revert it, remove the added entity from the collection
                collection.Remove(After as T);
            }
            else if (Before != null && DbEntityUtilities.IsIDbEntity(Before.GetType()) && After == null && !collection.Contains(Before as T))
            {
                // This property change refers to an entity removed from this collection. To revert it, re-add the removed entity to the collection
                collection.Add(Before as T);
            }
        }
        private void ApplyCollectionChange <T>(IEnumerable entities)
            where T : class, IDbEntity
        {
            // If remove (i.e. before = typeof(IDbEntity), after = null), remove before value
            ICollection <T> collection = entities as ICollection <T>;

            if (Before == null && After != null && DbEntityUtilities.IsIDbEntity(After.GetType()) && !collection.Contains(After as T))
            {
                // This property change refers to a newly added entity to this collection. To re-apply it, re-add the added entity to the collection
                collection.Add(After as T);
            }
            else if (Before != null && DbEntityUtilities.IsIDbEntity(Before.GetType()) && After == null)
            {
                // This property change refers to an entity removed from this collection. To re-apply it, remove the removed entity from the collection
                collection.Remove(Before as T);
            }
        }