コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="keys"></param>
        /// <param name="oldValues"></param>
        /// <returns></returns>
        protected override int ExecuteDelete(IDictionary keys, IDictionary oldValues)
        {
            if (owner.DeleteFunction == null)
                throw new DelegateNotFoundException("DeleteFunction", "The delete function doesn't implemented.");

            if (owner.IdentifierFunction == null)
                throw new DelegateNotFoundException("IdentifierFunction", "The identifier function doesn't implemented.");

            var eventArg = new DeletingEventArgs(owner.SourceType, owner.IdentifierFunction.Invoke(keys));
            owner.OnDeleting(eventArg);

            if (eventArg.Cancel)
                return 0;

            var deletingActionEvent = new ActionEventArgs<DeletingEventArgs, IPersisterResult>(eventArg, owner.DeleteFunction);

            var result = deletingActionEvent.Execute();
            if (result.QueryException != null)
            {
                owner.OnExecutionQueryError(new QueryResultEventArgs(result));
                return -1;
            }

            owner.OnDeleted(EventArgs.Empty);
            OnDataSourceViewChanged(EventArgs.Empty);
            return 1;
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public IPersisterResult DeleteFunction(DeletingEventArgs parameter)
        {
            ITransactionProvider tr = customDAO.GetTransactionProvider();
            lock (customDAO)
            {
                try
                {
                    tr.BeginTransaction("DeleteFunction", IsolationLevel.ReadCommitted);

                    int res = customDAO.MakeHQLQuery(string.Format("delete {0} cls where cls.id= :key", parameter.SourceType.Name))
                                    .SetParameter("key", parameter.Key)
                                    .ExecuteUpdate();

                    tr.CommitTransaction();

                    return new PersisterResult(parameter.SourceType, res);

                }
                catch (Exception ex)
                {
                    tr.RollbackTransaction(ex);
                    return new PersisterResult(parameter.SourceType, new ExecutionQueryException("Error on executing the delete function.", "DeleteFunction", ex));
                }
            }
        }
コード例 #3
0
 internal void OnDeleting(DeletingEventArgs e)
 {
     if (Deleting != null) Deleting(this, e);
 }