protected virtual void BuildSchema(Configuration config, bool blowDbAway, bool showSql, string schemaExportLocation, ISessionEventSubscriber sessionEventSubscriber, Action<Configuration> nhibConfigCallback) { config.LinqToHqlGeneratorsRegistry<NhibExtensionsRegistry>(); if (sessionEventSubscriber != null && sessionEventSubscriber.GetType() != typeof(NoOpSessionEventSubscriber)) { config.Interceptor = new SessionEventPublishingInterceptor(sessionEventSubscriber); } else { if (showSql) config.Interceptor = new LoggingInterceptor(); } if (nhibConfigCallback != null) { nhibConfigCallback.Invoke(config); } if (!blowDbAway) return; var schemaExport = new SchemaExport(config); if (!string.IsNullOrEmpty(schemaExportLocation)) schemaExport.SetOutputFile(schemaExportLocation); schemaExport.Execute(!string.IsNullOrEmpty(schemaExportLocation), true, false); }
public ISessionFactory GetSessionFactory(IDatabaseConfigurationParams configurationParams, ISessionEventSubscriber sessionEventSubscriber, Action<Configuration> nhibConfigCallback) { return Fluently.Configure() .Database(ConfigureDbWith(configurationParams)) .Mappings( m => configurationParams.Assemblies.ToList().ForEach( assembly => m.FluentMappings.AddFromAssembly(assembly))) .ExposeConfiguration( cfg => BuildSchema(cfg, configurationParams.BlowDbAway, configurationParams.ShowSql, configurationParams.SchemaExportLocation, sessionEventSubscriber, nhibConfigCallback)) .BuildSessionFactory(); }
public SessionEventPublishingInterceptor(ISessionEventSubscriber sessionEventSubscriber) { _sessionEventSubscriber = sessionEventSubscriber; }
public ISessionFactory GetSessionFactory(IDatabaseConfigurationParams configurationParams, ISessionEventSubscriber sessionEventSubscriber) { return GetSessionFactory(configurationParams, sessionEventSubscriber, null); }