当前位置: 首页>>代码示例>>C#>>正文


C# ISessionFactory.GetCurrentSession方法代码示例

本文整理汇总了C#中ISessionFactory.GetCurrentSession方法的典型用法代码示例。如果您正苦于以下问题:C# ISessionFactory.GetCurrentSession方法的具体用法?C# ISessionFactory.GetCurrentSession怎么用?C# ISessionFactory.GetCurrentSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISessionFactory的用法示例。


在下文中一共展示了ISessionFactory.GetCurrentSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckSession

        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();
        }
开发者ID:RichardPAsch,项目名称:PIMS,代码行数:17,代码来源:NHibernateConfiguration.cs

示例2: OpenSessionIfRequired

 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();
         }
     }
 }
开发者ID:grozeille,项目名称:chiffrage,代码行数:18,代码来源:CatalogSessionManagerService.cs

示例3: OpenSessionIfRequired

 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();
         }
     }
 }
开发者ID:grozeille,项目名称:chiffrage,代码行数:19,代码来源:SessionManager.cs

示例4: GetSession

 internal static ISession GetSession(ISessionFactory sessionFactory)
 {
     try {
         return sessionFactory.GetCurrentSession();
     }
     catch (HibernateException) { }
     ISession session = sessionFactory.OpenSession();
     session.FlushMode = FlushMode.Always;
     return session;
 }
开发者ID:nnarhinen,项目名称:fluentnhibernatedatagridmappingtest,代码行数:10,代码来源:Database.cs

示例5: EmailService

        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();
        }
开发者ID:MartinZulu,项目名称:LeTour,代码行数:10,代码来源:EmailService.cs

示例6: GetHandlerSequence

        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;
        }
开发者ID:brucewu16899,项目名称:lacjam,代码行数:11,代码来源:HandlerSequenceRespository.cs

示例7: Load

        public static void Load( ISessionFactory sessionFactory )
        {
            LoadDependencies( sessionFactory );

             var session = sessionFactory.GetCurrentSession();

             if (!session.DataAlreadyLoaded<WorkItemStatus>())
             {
            CreateTestModelData( sessionFactory );
            session.LoadIntoDatabase( ModelData );
             }
        }
开发者ID:kensodemann,项目名称:HomeScrum,代码行数:12,代码来源:WorkItemStatuses.cs

示例8: NHibernateUnitOfWorkScope

        public NHibernateUnitOfWorkScope(ISessionFactory sessionFactory)
        {
            this.sessionFactory = sessionFactory;
            ownsSession = !CurrentSessionContext.HasBind(sessionFactory);
            if (ownsSession)
            {
                session = sessionFactory.OpenSession();
                CurrentSessionContext.Bind(session);
                return;
            }

            session = sessionFactory.GetCurrentSession();
        }
开发者ID:craigo,项目名称:EmployeeManagement,代码行数:13,代码来源:NHibernateUnitOfWorkScope.cs

示例9: GetRoles

        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);

            }
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:18,代码来源:UserService.svc.cs

示例10: GetIncludingRoleByIdsAndCompanyId

        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);
                
            }
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:19,代码来源:UserService.svc.cs

示例11: GetCurrentSession

 public static ISession GetCurrentSession(ISessionFactory sessionFactory)
 {
     return sessionFactory.GetCurrentSession();
 }
开发者ID:rudygt,项目名称:ServiceStack,代码行数:4,代码来源:NHibernateUserAuthRepository.cs

示例12: GetOrOpenSession

        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;
        }
开发者ID:dylanmei,项目名称:nhibernate-mspec-bootstrap,代码行数:9,代码来源:SpecDb.cs

示例13: Init

        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;
        }
开发者ID:smartinz,项目名称:smartinzcoding,代码行数:43,代码来源:BaseTest.cs

示例14: LocalizationFilter

 public LocalizationFilter(ISessionFactory sessionFactory)
 {
     CurrentSession = sessionFactory.GetCurrentSession();
 }
开发者ID:MartinZulu,项目名称:LeTour,代码行数:4,代码来源:LocalizationFilter.cs

示例15: DeletePostCommand

 public DeletePostCommand(ISessionFactory sessionFactory)
 {
     _session = sessionFactory.GetCurrentSession();
 }
开发者ID:Detroier,项目名称:playground,代码行数:4,代码来源:DeletePostCommand.cs


注:本文中的ISessionFactory.GetCurrentSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。