Example #1
0
        internal virtual void OnEntityChanging(EntityChangingEventArgs args)
        {
            EventHandler <EntityChangingEventArgs> handler = EntityChanging;

            if (handler != null)
            {
                try {
                    handler(this, args);
                } catch {
                    // Eat any handler exceptions during load (query or import) - throw for all others.
                    if (!(args.Action == EntityAction.AttachOnQuery || args.Action == EntityAction.AttachOnImport))
                    {
                        throw;
                    }
                }
            }
        }
Example #2
0
        internal bool OnEntityChanging(IEntity entity, EntityAction action)
        {
            EventHandler <EntityChangingEventArgs> handler = EntityChanging;

            if (handler != null)
            {
                var args = new EntityChangingEventArgs(entity, action);
                try {
                    handler(this, args);
                    return(!args.Cancel);
                } catch {
                    // Eat any handler exceptions during load (query or import) - throw for all others.
                    if (!(args.Action == EntityAction.AttachOnQuery || args.Action == EntityAction.AttachOnImport))
                    {
                        throw;
                    }
                }
            }
            return(true);
        }