protected override void AdjustConfiguration(NHibernate.Cfg.Configuration cfg) { /* * NHibernate.Context.CallSessionContext * NHibernate.Context.ManagedWebSessionContext * NHibernate.Context.MapBasedSessionContext * NHibernate.Context.ReflectiveHttpContext * NHibernate.Context.ThreadLocalSessionContext * NHibernate.Context.ThreadStaticSessionContext * NHibernate.Context.WcfOperationSessionContext * NHibernate.Context.WebSessionContext */ cfg.CurrentSessionContext <ThreadStaticSessionContext>(); }
protected SessionFactoryProvider(IConfiguration configuration, string nick, IInterceptor interceptor) { connectionInfo = configuration.GetSection("db") .Get <ConnectionInfo[]>() .SingleOrDefault(ci => ci.Nick == nick && ci.DbServerType == ServerType); if (connectionInfo == null) { throw new InvalidOperationException($"Connection with name {nick} is not found"); } nhConfig = new NhConfiguration(); nhConfig.CurrentSessionContext <ThreadLocalSessionContext>(); nhConfig.SetProperty(Environment.SessionFactoryName, nick); nhConfig.Interceptor = interceptor ?? new EmptyInterceptor(); nhConfig.SetProperty(Environment.UseSecondLevelCache, "false"); nhConfig.SetProperty(Environment.ConnectionProvider, typeof(DriverConnectionProvider).AssemblyQualifiedName); Logger.LogDebug("NHibernate configuration: " + $"DbNick: {nhConfig.GetProperty(Environment.SessionFactoryName)}, " + $"UseSecondLevelCache: {nhConfig.GetProperty(Environment.UseSecondLevelCache)}, " + $"CacheDefaultExpiration: {nhConfig.GetProperty(Environment.CacheDefaultExpiration)}"); Nick = nick; IsSkipHealthCheckEntity = connectionInfo.IsSkipHealthCheckEntity; }