public void EntityAfterSaved(object sender, EntityEventArgs e)
 {
     if (IsTargetEntity(sender))
     {
         OnEntityAfterSaved(sender, e);
     }
 }
        public void RaiseAfterEvent(object sender, EntityEventArgs args)
        {
            Initialize();

            if (EntityAfter != null)
            {
                //EntityAfter.Invoke(sender, args);
                EntityAfter(sender, args);
            }
        }
        public void RaiseBeforeEvent(object sender, EntityEventArgs args)
        {
            Initialize();

            if (EntityBefore != null)
            {
                //EntityBefore.Invoke(sender, args);
                EntityBefore(sender, args);
            }
        }
        public void RaiseAfterEvent(object sender, EntityEventArgs args)
        {
            Initialize();

            if (EntityAfter != null)
            {
                //EntityAfter.Invoke(sender, args);
                EntityAfter(sender, args);
            }
        }
        public void RaiseBeforeEvent(object sender, EntityEventArgs args)
        {
            Initialize();

            if (EntityBefore != null)
            {
                //EntityBefore.Invoke(sender, args);
                EntityBefore(sender, args);
            }
        }
        private EntityEventArgs CreateArgs(DbEntityEntry item, EntityState state)
        {
            PropertyValues originalValues = null;
            PropertyValues currentValues = null;

            if (state == EntityState.Modified && !(item.State == EntityState.Detached))
            {
                originalValues = new PropertyValues(item.OriginalValues);
                currentValues = new PropertyValues(item.CurrentValues);
            }

            var args = new EntityEventArgs(state, originalValues, currentValues);
            return args;
        }
        protected override void OnEntityAfterSaved(object sender, EntityEventArgs e)
        {
            T tItem = (T)sender;

            switch (e.State)
            {
            case EntityState.Added:
                this.OnAfterInsert(tItem, e);
                break;

            case EntityState.Deleted:
                this.OnAfterDelete(tItem, e);
                break;

            case EntityState.Modified:
                this.OnAfterUpdate(tItem, e);
                break;
            }
        }
Exemple #8
0
 protected abstract void OnEntityAfterSaved(object sender, EntityEventArgs e);
Exemple #9
0
 protected abstract void OnEntityBeforeSaved(object sender, EntityEventArgs e);
 protected abstract void OnEntityAfterSaved(object sender, EntityEventArgs e);
 protected abstract void OnEntityBeforeSaved(object sender, EntityEventArgs e);
 public virtual void OnAfterDelete(T item, EntityEventArgs e)
 {
     return;
 }
 public virtual void OnBeforeDelete(T item, EntityEventArgs e)
 {
     return;
 }
 public virtual void OnAfterInsert(T item, EntityEventArgs e)
 {
     return;
 }
 public virtual void OnBeforeInsert(T item, EntityEventArgs e)
 {
     return;
 }