public ExposeConfiguration ( Action |
||
config | Action |
Lambda used to alter Configuration |
return |
static void CreateDatabaseWhenDebug(FluentConfiguration configuration) { #if DEBUG if (configuration == null) throw new ArgumentNullException("configuration"); configuration.ExposeConfiguration( config => new SchemaUpdate(config).Execute(false, true)); #endif }
/// <summary> /// Create database structure from entities /// </summary> /// <param name="configuration">The configuration.</param> public static void Export(FluentConfiguration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); Configuration config = null; configuration.ExposeConfiguration(c => config = c); var factory = configuration.BuildSessionFactory(); var export = new SchemaExport(config); export.Execute(false, true, false, factory.OpenSession().Connection, null); }
private static void ApplyDefaultsTo(FluentConfiguration fluentConfiguration) { fluentConfiguration.ExposeConfiguration( c => { c.SetProperty("current_session_context_class",typeof(ThreadStaticSessionContext).AssemblyQualifiedName); //default to LinFu if not specifed by user if (!c.Properties.Keys.Contains(PROXY_FACTORY_KEY)) c.SetProperty(PROXY_FACTORY_KEY,typeof(ProxyFactoryFactory).AssemblyQualifiedName); } ); }
private static FluentConfiguration AttachePocoEvents(FluentConfiguration config) { return config.ExposeConfiguration(x => x.EventListeners.PreInsertEventListeners = new IPreInsertEventListener[] {new AuditListener()}) .ExposeConfiguration(x => x.EventListeners.PreUpdateEventListeners = new IPreUpdateEventListener[] {new AuditListener()}); }
static void BuildConfiguration(Boolean createDb=false) { var dCnf = SQLiteConfiguration.Standard.ConnectionString(String.Format("Data Source={0};Version=3;", DbFile)). UsingFile(DbFile).ShowSql(); configuration = Fluently.Configure() .Database(dCnf) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<EmployeeMap>()) .Diagnostics(x => x.Enable()); if (createDb) { // delete the existing db on each run File.Delete(DbFile); configuration.ExposeConfiguration(BuildSchema); } }