private void HandleRunQuery <TNextActionType>(Func <IQueryableRepository <TEntity>, TNextActionType> queryableRepositoryOperation, Action <TNextActionType> operationToExecuteBeforeNextOperation)
        {
            CheckForObjectAlreadyDisposedOrNot(typeof(QueryableRepository <TEntity>).FullName);
            ContractUtility.Requires <ArgumentNullException>(queryableRepositoryOperation.IsNotNull(), "queryableRepositoryOperation instance cannot be null");
            Action operation = () =>
            {
                TNextActionType queryReturnValue = _unitOfWork.IsNull() ?
                                                   ExceptionHandlingUtility.HandleExceptionWithNullCheck(
                    () => queryableRepositoryOperation(this), _exceptionHandler)
                                                   : queryableRepositoryOperation(this);
                //TODO - proper exception handling compensating handler needs to be here
                if (operationToExecuteBeforeNextOperation.IsNotNull())
                {
                    operationToExecuteBeforeNextOperation(queryReturnValue);
                }
            };

            if (_unitOfWork.IsNotNull())
            {
                _unitOfWork.AddOperation(operation);
            }
            else
            {
                operation();
            }
        }
コード例 #2
0
 /// <summary>
 /// While using this API alongwith unit of work instance, this API's return value should
 /// not be used as the actual return value for the commit.But rather the internal unit of work's
 /// Commit method's return value should be used.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public override void Insert(TEntity item, Action operationToExecuteBeforeNextOperation = null)
 {
     CheckForObjectAlreadyDisposedOrNot(typeof(CommandRepository <TEntity>).FullName);
     ContractUtility.Requires <ArgumentNullException>(item.IsNotNull(), "item instance cannot be null");
     if (_unitOfWork.IsNotNull())
     {
         _unitOfWork.AddOperation(() => ActualInsert(item, operationToExecuteBeforeNextOperation));
     }
     else
     {
         //TODO - proper exception handling compensating handler needs to be here
         ExceptionHandlingUtility.HandleExceptionWithNullCheck(() => ActualInsert(item, operationToExecuteBeforeNextOperation), _exceptionHandler);
     }
 }
        public virtual void RunQuery(Func <IQueryableRepository <TEntity>, TEntity> queryableRepositoryOperation, Action <TEntity> operationToExecuteBeforeNextOperation = null)
        {
            CheckForObjectAlreadyDisposedOrNot(typeof(QueryableRepository <TEntity>).FullName);
            ContractUtility.Requires <ArgumentNullException>(queryableRepositoryOperation.IsNotNull(), "queryableRepositoryOperation instance cannot be null");
            Action operation = () =>
            {
                var queryReturnValue = queryableRepositoryOperation(this);
                if (operationToExecuteBeforeNextOperation.IsNotNull())
                {
                    operationToExecuteBeforeNextOperation(queryReturnValue);
                }
            };

            if (_unitOfWork.IsNotNull())
            {
                _unitOfWork.AddOperation(operation);
            }
            else
            {
                operation();
            }
        }
 /// <summary>
 /// While using this API alongwith unit of work instance, this API's return value should
 /// not be used as the actual return value for the commit.But rather the internal unit of work's
 /// Commit method's return value should be used.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public override void Insert(TEntity item, Action operationToExecuteBeforeNextOperation = null)
 {
     CheckForObjectAlreadyDisposedOrNot(typeof(CommandRepository <TEntity>).FullName);
     ContractUtility.Requires <ArgumentNullException>(item.IsNotNull(), "item instance cannot be null");
     if (_unitOfWork.IsNotNull())
     {
         _unitOfWork.AddOperation(() => ActualInsert(item));
     }
     else
     {
         ActualInsert(item);
     }
 }