FluentNHibernate.SessionSource.CreateSession C# (CSharp) Method

CreateSession() public method

public CreateSession ( ) : ISession
return ISession
        public virtual ISession CreateSession()
        {
            return sessionFactory.OpenSession();
        }

Usage Example

        /// <summary>
        /// Configures the storage with the user supplied persistence configuration
        /// Azure tables are created if requested by the user
        /// </summary>
        /// <param name="config"></param>
        /// <param name="connectionString"></param>
        /// <param name="createSchema"></param>
        /// <returns></returns>
        public static Configure AzureSubcriptionStorage(this Configure config,
            string connectionString,
            bool createSchema)
        {
            var database = MsSqlConfiguration.MsSql2005
                .ConnectionString(connectionString)
                .Provider(typeof(TableStorageConnectionProvider).AssemblyQualifiedName)
                .Dialect(typeof(TableStorageDialect).AssemblyQualifiedName)
                .Driver(typeof(TableStorageDriver).AssemblyQualifiedName)
                .ProxyFactoryFactory(typeof(ProxyFactoryFactory).AssemblyQualifiedName);

            var fluentConfiguration = Fluently.Configure()
                .Database(database)
                .Mappings(m => m.FluentMappings.Add(typeof (SubscriptionMap)));
            var configuration = fluentConfiguration.BuildConfiguration();

            var sessionSource = new SessionSource(fluentConfiguration);

            if (createSchema)
            {
                using (var session = sessionSource.CreateSession())
                {
                    new SchemaExport(configuration).Execute(true, true, false, session.Connection, null);
                    session.Flush();
                }
            }

            config.Configurer.RegisterSingleton<ISessionSource>(sessionSource);
            config.Configurer.ConfigureComponent<SubscriptionStorage>(DependencyLifecycle.InstancePerCall);

            return config;
        }
All Usage Examples Of FluentNHibernate.SessionSource::CreateSession