private void AssertCurrentSession(ISessionFactory factory, ISession session, string message)
 {
     Assert.That(
         factory.GetCurrentSession(),
         Is.EqualTo(session),
         "{0} {1} instead of {2}.", message,
         factory.GetCurrentSession().GetSessionImplementation().SessionId,
         session.GetSessionImplementation().SessionId);
 }
        public void BeginTransaction()
        {
            var session = _sessionFactory.GetCurrentSession();

            if (session != null)
            {
                session.BeginTransaction();
            }
        }
Пример #3
0
        private const string CurrentSessionKey = "nhibernate.current_session"; // added 3-31-15

        #endregion Fields

        #region Methods

        // Bind, if necessary, the current HttpContext to NHibernate's ISession.
        public static ISession CheckSession(ISessionFactory sf)
        {
            if (CurrentSessionContext.HasBind(sf))
                return sf.GetCurrentSession();

            var newSession = sf.OpenSession();
            CurrentSessionContext.Bind(newSession);

            return sf.GetCurrentSession();
        }
Пример #4
0
        public void BeginTransaction()
        {
            if (!CurrentSessionContext.HasBind(_sessionFactory))
            {
                CurrentSessionContext.Bind(_sessionFactory.OpenSession());
            }

            _session = _sessionFactory.GetCurrentSession();
            _session.BeginTransaction();
        }
        public void BeginTransaction()
        {
            if (!CurrentSessionContext.HasBind(_sessionFactory))
            {
                return;
            }
            var session = _sessionFactory.GetCurrentSession();

            session?.BeginTransaction();
        }
Пример #6
0
        public static ISession PegaSessaoEmUso()
        {
            ISession sessao = fabricaDeSessao.GetCurrentSession();

            if (sessao == null)
            {
                sessao = fabricaDeSessao.OpenSession();
            }

            return(sessao);
        }
        public IList <Transporte> GetMasCercanos(Point origen, int maxDistance)
        {
            var session = sessionFactory.GetCurrentSession();
            var query   = session.CreateQuery(@"select t from Transporte t 
                                        where NHSP.Distance(t.Ubicacion, :coord) <= :maxDistance 
                                        order by NHSP.Distance(t.Ubicacion, :coord)")
                          .SetParameter("coord", origen, NHibernateUtil.Custom(typeof(Wgs84GeographyType)))
                          .SetDouble("maxDistance", maxDistance);

            return(query.List <Transporte>());
        }
Пример #8
0
        /// <summary>
        /// Trae todas las Categorías (de una parte)
        /// </summary>
        /// <param name="tipoCategoria">1 Ficha Técnica | 2 Equipamineto</param>
        /// <param name="paisId"></param>
        /// <returns></returns>
        public IList <Hotel> GetCategorias(int tipoCategoria, int paisId)
        {
            var session = sessionFactory.GetCurrentSession();
            var query   = session.CreateQuery("from Categoria as c where c.Pais.ID =:PaisID and c.TipoCategoria = :TipoCategoria order by c.Nombre")
                          .SetInt32("PaisID", paisId)
                          .SetInt32("TipoCategoria", tipoCategoria)
                          .SetReadOnly(true)
                          .SetCacheable(true)
                          .SetCacheRegion("static");

            return(query.List <Hotel>());
        }
Пример #9
0
        public IDictionary <City, int> CountAdsByCity()
        {
            var query = (from c in _sessionFactory.GetCurrentSession().Query <City>().Fetch(x => x.Province)
                         select new { City = c, Count = c.Ads.Count });

            IDictionary <City, int> result = query.ToList().ToDictionary(x => x.City, x => x.Count);

            return(result);
        }
        public void BeginTransaction()
        {
            if (CurrentSessionContext.HasBind(_sessionFactory) == false)
            {
                return;
            }
            var session = _sessionFactory.GetCurrentSession();

            if (session != null)
            {
                session.BeginTransaction();
            }
        }
Пример #11
0
        public void TestGetCategoryFromLabel_NoMatch_ReturnNull()
        {
            ISessionFactory    sessionFactory = NhibernateHelper.SessionFactory;
            CategoryRepository catRepo        = new CategoryRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                sessionFactory.GetCurrentSession().Save(new Category()
                {
                    Label = "label", LabelUrlPart = "url"
                });
                Assert.IsNull(catRepo.GetCategoryFromLabel("zeuh"));
            }
        }
Пример #12
0
        public void BeginTransaction()
        {
            if (!CurrentSessionContext.HasBind(sessionFactory))
            {
                return;
            }

            var session = sessionFactory.GetCurrentSession();

            if (null != session)
            {
                session.BeginTransaction();
            }
        }
        public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
        {
            IMethodReturn result;

            using (ITransaction tx = _sessionFactory.GetCurrentSession().BeginTransaction())
            {
                result = getNext()(input, getNext);
                if (result.Exception == null)
                {
                    _sessionFactory.GetCurrentSession().Flush();
                    tx.Commit();
                }
            }
            return(result);
        }
Пример #14
0
        public ISession GetSession()
        {
            ISession session;

            if (CurrentSessionContext.HasBind(_sessionFactory))
            {
                session = _sessionFactory.GetCurrentSession();
            }
            else
            {
                session = _sessionFactory.OpenSession();
            }

            return(session);
        }
Пример #15
0
        public static ISession GetCurrentSession()
        {
            ISession session = sessionFactory.GetCurrentSession();

            if (session == null)
            {
                session = sessionFactory.OpenSession();
                //ConfigurationManager.AppSettings[CurrentSessionKey] = session.ToString();
            }
            else
            {
                session = sessionFactory.GetCurrentSession();
            }
            return(session);
        }
Пример #16
0
        public void Dispose()
        {
            if (!CurrentSessionContext.HasBind(_sessionFactory))
            {
                throw new InvalidOperationException("Invalid current session");
            }

            ISession session = _sessionFactory.GetCurrentSession();

            CurrentSessionContext.Unbind(_sessionFactory);

            if (!session.IsOpen)
            {
                throw new InvalidOperationException("Session closed before disposing context");
            }

            if (null != session.Transaction && session.Transaction.IsActive)
            {
                if (session.Transaction.WasCommitted == false && session.Transaction.WasRolledBack == false)
                {
                    session.Transaction.Rollback();
                }
            }

            session.Close();
        }
Пример #17
0
        public static ISession GetSession()
        {
            ISession session;

            if (NHibernate.Context.CurrentSessionContext.HasBind(SessionFactory))
            {
                session = sessionFactory.GetCurrentSession();
            }
            else
            {
                //session = sessionFactory.OpenSession(new Arbinada.GenieLamp.Warehouse.Patterns.CommonEntityInterceptor());
                session = sessionFactory.OpenSession();
                NHibernate.Context.CurrentSessionContext.Bind(session);
            }
            return(session);
        }
 public Voyage find(VoyageNumber voyageNumber)
 {
     return(sessionFactory.GetCurrentSession().
            CreateQuery("from Voyage where VoyageNumber = :vn").
            SetParameter("vn", voyageNumber).
            UniqueResult <Voyage>());
 }
Пример #19
0
        /// <summary>
        /// Gets the session.
        /// </summary>
        /// <returns>An ISession object.</returns>
        public ISession GetSession()
        {
            ISessionFactory sessionFactory = _sessionFactoryProvider.GetFactory(null); // Bind seesion to the context etc.
            ISession        session        = sessionFactory.GetCurrentSession();

            return(session);
        }
Пример #20
0
        public override async Task SaveCurrentCheckpointAsync(string projectorIdentifier, int checkpoint)
        {
            var session = CurrentSessionContext.HasBind(sessionFactory) ?
                          sessionFactory.GetCurrentSession() :
                          sessionFactory.OpenSession();

            var checkpointInfo = await session.GetAsync <TCheckpointInfo>(projectorIdentifier);

            if (checkpointInfo == null)
            {
                checkpointInfo = new TCheckpointInfo
                {
                    StateModel       = projectorIdentifier,
                    CheckpointNumber = checkpoint
                };

                session.Save(checkpointInfo);
            }
            else
            {
                checkpointInfo.CheckpointNumber = checkpoint;

                session.Update(checkpointInfo);
            }

            // session.Flush();

            if (!CurrentSessionContext.HasBind(sessionFactory))
            {
                await session.FlushAsync();

                session.Dispose();
            }
        }
        public void Save(long eventSequence, string name)
        {
            var handlerSequence = GetHandlerSequence(_sessionFactory, name);

            handlerSequence.UpdateSequence(eventSequence);
            _sessionFactory.GetCurrentSession().Update(handlerSequence);
        }
Пример #22
0
        public static ISession GetSession()
        {
            ISession session;

            if (NHibernate.Context.CurrentSessionContext.HasBind(SessionFactory))
            {
                session = sessionFactory.GetCurrentSession();
            }
            else
            {
                session = sessionFactory.OpenSession(new GenieLamp.Examples.QuickStart.Patterns.CommonEntityInterceptor());
                //session = sessionFactory.OpenSession();
                NHibernate.Context.CurrentSessionContext.Bind(session);
            }
            return(session);
        }
Пример #23
0
        protected void Application_EndRequest(object sender, EventArgs e)
        {
            var session     = SessionFactory.GetCurrentSession();
            var transaction = session.Transaction;

            if (transaction == null || !transaction.IsActive)
            {
                return;
            }
            try
            {
                transaction.Commit();
            }
            catch (Exception err)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                throw err;
            }
            finally
            {
                session = CurrentSessionContext.Unbind(SessionFactory);
                session.Close();
            }
        }
Пример #24
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            // Register all controllers from this assembly

            container.Register(
                Types.FromThisAssembly()
                .BasedOn <IController>()
                .Configure(c => c.LifestyleTransient())

                /*
                 * container.Register(Types.FromThisAssembly()
                 *             .BasedOn<Controller>()
                 *               .LifestyleTransient()*/

                );

            // Register HttpContext(Base) and HttpRequest(Base) so it automagically can be injected using IoC
            container.AddFacility <FactorySupportFacility>();
            container.Register(Component.For <HttpRequestBase>().LifeStyle.Transient
                               .UsingFactoryMethod(() => new HttpRequestWrapper(HttpContext.Current.Request)));
            container.Register(Component.For <HttpContextBase>().LifeStyle.Transient
                               .UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));

            container.Register(Component.For <ISession>().UsingFactoryMethod(() => _sessionFactory.GetCurrentSession()).LifeStyle.Transient);
        }
Пример #25
0
        private ISession getAmbientSession(bool openIfNeeded)
        {
            if (AppConfiguration.ConversationIsolationLevel == 1)
            {
                return(createSession());
            }
            ISession session = null;

            try
            {
                session = sessionFactory.GetCurrentSession();
                if (session == null && openIfNeeded)    // && !AppConfiguration.IsWebContext)
                {
                    session = createSingletonSession(); // it is used in the cases where no HTTP request context is available and session per HTTP request does not work.
                }
                //this flush mode will flush on manual flushes and when transactions are committed.
                if (session != null)
                {
                    session.FlushMode = FlushMode.Commit;
                }
            }
            catch
            { }
            if (session == null)
            {
                throw new Exception("Could not acquire a session to access the data.");
            }
            return(session);
        }
Пример #26
0
        public void GetAdType_CarAdExists_ReturnType()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository      repo           = new Repository(sessionFactory);
            AdRepository    adRepo         = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email    = "*****@*****.**",
                    Password = "******"
                };
                repo.Save <User>(u);

                City c = new City
                {
                    Label        = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label        = "Auto",
                    LabelUrlPart = "Auto",
                    Type         = AdTypeEnum.CarAd
                };

                CarAd a = new CarAd
                {
                    Title        = "honda civic type R",
                    Body         = "the best!!",
                    CreatedBy    = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category     = cat,
                    Kilometers   = 25000,
                    Year         = 1998
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save <Province>(p1);
                repo.Save <City>(c);
                repo.Save <Category>(cat);
                long id = repo.Save <CarAd, long>(a);

                repo.Flush();

                #endregion

                Assert.AreEqual(AdTypeEnum.CarAd, adRepo.GetAdType(id));
            }
        }
Пример #27
0
        public void CarAd_mapping_standalonetable()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            IRepository     repo           = new Repository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                Province p = new Province {
                    Label = "Province Sud"
                };
                City c = new City {
                    Label = "Nouméa", Province = p, LabelUrlPart = "city"
                };
                p.AddCity(c);
                repo.Save(p);
                repo.Save(c);

                User u = new User
                {
                    Email    = "email",
                    Password = "******"
                };
                repo.Save(u);

                Category cat = new Category
                {
                    Label        = "label",
                    LabelUrlPart = "label"
                };
                repo.Save(cat);

                CarAd carAd = new CarAd()
                {
                    Title        = "title",
                    Body         = "bidy",
                    CreationDate = DateTime.Now,
                    IsOffer      = true,
                    CreatedBy    = u,
                    City         = c,
                    Category     = cat,
                    Kilometers   = 2000,
                    Year         = 2013
                };
                repo.Save(carAd);

                Ad ad = new Ad()
                {
                    Title        = "title",
                    Body         = "bidy",
                    CreationDate = DateTime.Now,
                    IsOffer      = true,
                    CreatedBy    = u,
                    City         = c,
                    Category     = cat
                };
                repo.Save(ad);
                repo.Flush();
            }
        }
Пример #28
0
 /// <summary>
 /// 获取与当前请求相关的ISession,同一个请求共享一个ISession对象。
 /// </summary>
 /// <returns></returns>
 public ISession GetCurrentSession()
 {
     if (!CurrentSessionContext.HasBind(factory))
     {
         CurrentSessionContext.Bind(this.OpenSession());
     }
     return(factory.GetCurrentSession());
 }
Пример #29
0
        /// <summary>
        /// Disposes of the current session returned by <see cref="ISessionFactory.GetCurrentSession"/> and unbinds it
        /// from <see cref="CurrentSessionContext"/>. If the current session has an active transaction, this will be rolled back.
        /// </summary>
        /// <param name="sessionFactory">The session factory that will return the current session</param>
        public static void DisposeCurrentSession(this ISessionFactory sessionFactory)
        {
            ISession currentSession = sessionFactory.GetCurrentSession();

            //this will rollback any active NHibernate transaction
            currentSession.Dispose();
            CurrentSessionContext.Unbind(sessionFactory);
        }
Пример #30
0
 public void Intercept(IInvocation invocation)
 {
     using (var transaction = _sessionFactory.GetCurrentSession().BeginTransaction(IsolationLevel.ReadCommitted))
     {
         invocation.Proceed();
         transaction.Commit();
     }
 }
Пример #31
0
        public async Task <Unit> Handle(CreateTodoCommand request, CancellationToken cancellationToken)
        {
            var session = _sessionFactory.GetCurrentSession();
            var todo    = new Todo(request.Data.Task);
            await session.SaveAsync(todo, cancellationToken);

            return(Unit.Value);
        }
 public ISession OpenSessionIfRequired(ISessionFactory sessionFactory)
 {
     if (CatalogSessionContext.HasBind(sessionFactory))
     {
         return sessionFactory.GetCurrentSession();
     }
     else
     {
         lock (_syncRoot)
         {
             if (!CatalogSessionContext.HasBind(sessionFactory))
             {
                 CatalogSessionContext.Bind(sessionFactory.OpenSession());
             }
             return sessionFactory.GetCurrentSession();
         }
     }
 }
Пример #33
0
 public static ISession OpenSessionIfRequired(ISessionFactory sessionFactory)
 {
     if (EventStoreSessionContext.HasBind(sessionFactory))
     {
         return sessionFactory.GetCurrentSession();
     }
     else
     {
         lock (_syncRoot)
         {
             if (!EventStoreSessionContext.HasBind(sessionFactory))
             {
                 EventStoreSessionContext.Bind(sessionFactory.OpenSession());
                 logger.Info("EventStoreSessionContext.OpenSession");
             }
             return sessionFactory.GetCurrentSession();
         }
     }
 }
Пример #34
0
        public EmailService(string hostname, string sourceAddress, string contactAddress, bool testMode, ILogger logger, ISessionFactory sessionFactory)
        {
            defaultSmtpSender = new DefaultSmtpSender(hostname);

            this.sourceAddress = sourceAddress;
            this.contactAddress = contactAddress;
            this.testMode = testMode;
            this.logger = logger;
            this.session = sessionFactory.GetCurrentSession();
        }
 internal static ISession GetSession(ISessionFactory sessionFactory)
 {
     try {
         return sessionFactory.GetCurrentSession();
     }
     catch (HibernateException) { }
     ISession session = sessionFactory.OpenSession();
     session.FlushMode = FlushMode.Always;
     return session;
 }
        private static HandlerSequence GetHandlerSequence(ISessionFactory sessionFactory, string name)
        {
            var session = sessionFactory.GetCurrentSession();
            var sequence = session.Get<HandlerSequence>(name);
            if (sequence != null)
                return sequence;

            sequence = new HandlerSequence(name);
            session.Save(sequence);
            return sequence;
        }
Пример #37
0
        public static void Load( ISessionFactory sessionFactory )
        {
            LoadDependencies( sessionFactory );

             var session = sessionFactory.GetCurrentSession();

             if (!session.DataAlreadyLoaded<WorkItemStatus>())
             {
            CreateTestModelData( sessionFactory );
            session.LoadIntoDatabase( ModelData );
             }
        }
        public NHibernateUnitOfWorkScope(ISessionFactory sessionFactory)
        {
            this.sessionFactory = sessionFactory;
            ownsSession = !CurrentSessionContext.HasBind(sessionFactory);
            if (ownsSession)
            {
                session = sessionFactory.OpenSession();
                CurrentSessionContext.Bind(session);
                return;
            }

            session = sessionFactory.GetCurrentSession();
        }
Пример #39
0
        public RoleDto[] GetRoles(long companyId)
        {
            var rolesService =ObjectFactory.GetInstance<IRolesService>();

            _sessionFactory = ObjectFactory.GetInstance<IBusinessSafeSessionFactory>().GetSessionFactory();
            CurrentSessionContext.Bind(_sessionFactory.OpenSession());

            try
            {
                return rolesService.GetAllRoles(companyId).ToArray();
            }
            finally
            {
                _sessionFactory.GetCurrentSession().Dispose();
                CurrentSessionContext.Unbind(_sessionFactory);

            }
        }
Пример #40
0
        public UserDto[] GetIncludingRoleByIdsAndCompanyId(Guid[] ids, long companyId)
        {
            _applicationLayerUserService =
                ObjectFactory.GetInstance<BusinessSafe.Application.Contracts.Users.IUserService>();

            _sessionFactory = ObjectFactory.GetInstance<IBusinessSafeSessionFactory>().GetSessionFactory();
            CurrentSessionContext.Bind(_sessionFactory.OpenSession());

            try
            {
                return _applicationLayerUserService.GetIncludingRoleByIdsAndCompanyId(ids, companyId).ToArray();
            }
            finally
            {
                _sessionFactory.GetCurrentSession().Dispose();
                CurrentSessionContext.Unbind(_sessionFactory);
                
            }
        }
Пример #41
0
 public AuthorisationFilter(ISessionFactory sessionFactory)
 {
     this.session = sessionFactory.GetCurrentSession();
 }
Пример #42
0
 public CyclistsController(ISessionFactory sessionFactory)
 {
     this.session = sessionFactory.GetCurrentSession();
 }
Пример #43
0
 public PageOfPostsQuery(ISessionFactory sessionFactory)
 {
     _session = sessionFactory.GetCurrentSession();
 }
 public static ISession GetCurrentSession(ISessionFactory sessionFactory)
 {
     return sessionFactory.GetCurrentSession();
 }
Пример #45
0
        static ISession GetOrOpenSession(ISessionFactory sessionFactory)
        {
            if (NHibernate.Context.CurrentSessionContext.HasBind(sessionFactory))
              return sessionFactory.GetCurrentSession();

              var session = sessionFactory.OpenSession();
              NHibernate.Context.CurrentSessionContext.Bind(session);
              return session;
        }
Пример #46
0
 protected BaseController(ISessionFactory sessionFactory)
 {
     CurrentSession = sessionFactory.GetCurrentSession();
 }
Пример #47
0
        private ServiceLocatorImpl Init()
        {
            var nhConfig = new Configuration();
            Security.Configure<User>(nhConfig, SecurityTableStructure.Prefix);

            SessionFactory = nhConfig.Configure().BuildSessionFactory();
            CurrentSessionContext.Bind(SessionFactory.OpenSession());

            //var s = new SchemaExport(nhConfig);
            //s.SetOutputFile(@"c:\temp\out.txt");
            //s.Execute(true, false, false);

            NHibernate.Validator.Cfg.Environment.SharedEngineProvider.GetEngine().Configure();

            var impl = new ServiceLocatorImpl();
            ServiceLocator.SetLocatorProvider(() => impl);
            impl.Add(typeof(CategoryRepository), () => new CategoryRepository(SessionFactory));
            impl.Add(typeof(CustomerDemographicRepository), () => new CustomerDemographicRepository(SessionFactory));
            impl.Add(typeof(CustomerRepository), () => new CustomerRepository(SessionFactory));
            impl.Add(typeof(EmployeeRepository), () => new EmployeeRepository(SessionFactory));
            impl.Add(typeof(OrderDetailRepository), () => new OrderDetailRepository(SessionFactory));
            impl.Add(typeof(OrderRepository), () => new OrderRepository(SessionFactory));
            impl.Add(typeof(ProductRepository), () => new ProductRepository(SessionFactory));
            impl.Add(typeof(RegionRepository), () => new RegionRepository(SessionFactory));
            impl.Add(typeof(ShipperRepository), () => new ShipperRepository(SessionFactory));
            impl.Add(typeof(SupplierRepository), () => new SupplierRepository(SessionFactory));
            impl.Add(typeof(TerritoryRepository), () => new TerritoryRepository(SessionFactory));
            impl.Add(typeof(IStringConverter<Customer>), () => new CustomerStringConverter(new CustomerRepository(SessionFactory)));
            impl.Add(typeof(IStringConverter<Product>), () => new ProductStringConverter(new ProductRepository(SessionFactory)));
            impl.Add(typeof(IStringConverter<Category>), () => new CategoryStringConverter(new CategoryRepository(SessionFactory)));
            impl.Add(typeof(NHibernate.Validator.Engine.ValidatorEngine), () => NHibernate.Validator.Cfg.Environment.SharedEngineProvider.GetEngine());

            impl.Add(typeof(IAuthorizationRepository), () => new AuthorizationRepository(SessionFactory.GetCurrentSession()));
            impl.Add(typeof(IPermissionsService), () => new PermissionsService(ServiceLocator.Current.GetInstance<IAuthorizationRepository>(), SessionFactory.GetCurrentSession()));
            impl.Add(typeof(IAuthorizationService), () => new AuthorizationService(ServiceLocator.Current.GetInstance<IPermissionsService>(), ServiceLocator.Current.GetInstance<IAuthorizationRepository>()));
            impl.Add(typeof(IPermissionsBuilderService), () => new PermissionsBuilderService(SessionFactory.GetCurrentSession(), ServiceLocator.Current.GetInstance<IAuthorizationRepository>()));

            impl.Add(typeof(IEntityInformationExtractor<Customer>), () => new CustomerInformationExtractor());
            impl.Add(typeof(IEntityInformationExtractor<Product>), () => new ProductInformationExtractor());
            impl.Add(typeof(IEntityInformationExtractor<Category>), () => new CategoryInformationExtractor());

            return impl;
        }
Пример #48
0
 public AddPostCommand(ISessionFactory sessionFactory, IMapper<PostInsertViewModel, Post> postViewMapper)
 {
     _session = sessionFactory.GetCurrentSession();
     _postViewMapper = postViewMapper;
 }
Пример #49
0
 public AuthenticationFilter(ISessionFactory sessionFactory)
 {
     currentSession = sessionFactory.GetCurrentSession();
 }
 public HomeController(ISessionFactory sessionFactory)
 {
     this.session = sessionFactory.GetCurrentSession();
 }
Пример #51
0
 public LocalizationFilter(ISessionFactory sessionFactory)
 {
     CurrentSession = sessionFactory.GetCurrentSession();
 }
Пример #52
0
 public DeletePostCommand(ISessionFactory sessionFactory)
 {
     _session = sessionFactory.GetCurrentSession();
 }
Пример #53
0
        private static void BootstrapContainer()
        {
            Container = new WindsorContainer()
                .Install(FromAssembly.This());

            var controllerFactory = new WindsorControllerFactory(Container);
            ControllerBuilder.Current.SetControllerFactory(controllerFactory);

            var mappingConfiguration = new ConventionConfiguration();
            var config =
                new NHibernate.Cfg.Configuration().Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                                          "NHibernate.config"));
            var autoPersistenceModel =
                AutoMap.AssemblyOf<BabySitter>(mappingConfiguration)
                    .Conventions.Setup(c =>
                                           {
                                               c.Add<PrimaryKeyConvention>();
                                               c.Add<CustomForeignKeyConvention>();
                                               c.Add(DefaultCascade.All());
                                           })
                    .Override<BabySittingPointsView>(map =>
                                                         {
                                                             map.Table("vw_BabySittingPoints");
                                                             map.ReadOnly();
                                                             map.Id(x => x.Id, "BabySitterId");
                                                         });

            SessionFactory = Fluently.Configure(config)
                .Mappings(m =>
                {
                    m.AutoMappings.Add(autoPersistenceModel);
                    m.HbmMappings.AddFromAssemblyOf<MvcApplication>();
                })

                .BuildSessionFactory();

            Container.Register(Component.For<ISession>().UsingFactoryMethod(() => SessionFactory.GetCurrentSession()).LifestylePerWebRequest());
            //Container.Register(Component.For<ILogger>().ImplementedBy<NLogLogger>());
        }
Пример #54
0
 public QueryImpl(ISessionFactory s)
 {
     this.Session = s.GetCurrentSession();
 }