Esempio n. 1
0
        private static UnitOfWorkTransactionOptions GetUnitOfWorkOptions(NancyContext ctx)
        {
            object val;

            if (!ctx.Items.TryGetValue(UNIT_OF_WORK_OPTIONS, out val))
            {
                return(UnitOfWorkTransactionOptions.Default());
            }

            return(val as UnitOfWorkTransactionOptions ?? UnitOfWorkTransactionOptions.Default());
        }
Esempio n. 2
0
        public static Func <NancyContext, Response> BeforeEveryRequest(IContainer requestContainer)
        {
            return(ctx => {
                var unitOfWork = requestContainer.GetInstance <INHibernateUnitOfWork>();
                var scope = unitOfWork.CreateTransactionalScope(UnitOfWorkTransactionOptions.DirtyReads());
                var session = unitOfWork.CurrentSession;

                ctx.Items.Add(REQUEST_TRANSACTIONAL_SCOPE_KEY, scope);

                CurrentSessionContext.Bind(session);

                session.BeginTransaction();

                return ctx.Response;
            });
        }
Esempio n. 3
0
 public ITransactionalUnitOfWorkScope CreateTransactionalScope(UnitOfWorkTransactionOptions options)
 {
     return(new TransactionalUnitOfWorkScope(this, new NHibernateUnitOfWorkTransaction(this, options)));
 }
Esempio n. 4
0
 public ITransactionalUnitOfWorkScope CreateTransactionalScope()
 {
     return(CreateTransactionalScope(UnitOfWorkTransactionOptions.Default()));
 }
Esempio n. 5
0
 public NHibernateUnitOfWorkTransaction(INHibernateUnitOfWork unitOfWork, UnitOfWorkTransactionOptions options)
 {
     _unitOfWork = unitOfWork;
     _options    = options;
 }
 public void Begin()
 {
     _scope = _unitOfWork.CreateTransactionalScope(UnitOfWorkTransactionOptions.Default());
 }
 protected UnitOfWorkMessageHandler(UnitOfWorkTransactionOptions options)
 {
     _options = options;
     _log     = LogManager.GetLogger(GetType());
 }
 protected UnitOfWorkMessageHandler()
     : this(UnitOfWorkTransactionOptions.Default())
 {
 }