public Mappings ( Action |
||
mappings | Action |
Lambda used to apply mappings |
return |
protected virtual FluentConfiguration DoMappingsFromAssembly(FluentConfiguration fluentConfig) { return fluentConfig .Mappings(x => { x.FluentMappings.AddFromAssemblyOf<JackWeb.Data.Collectors.FacebookCollector>(); }); }
public void AddAvailableMappings(FluentConfiguration fluentConfiguration) { fluentConfiguration.Mappings(mc => mc.FluentMappings.AddFromAssemblyOf<PagePropertiesMap>()); fluentConfiguration.Mappings(mc => mc.FluentMappings.AddFromAssemblyOf<PageMap>()); fluentConfiguration.Mappings(mc => mc.FluentMappings.AddFromAssemblyOf<MediaMap>()); fluentConfiguration.Mappings(mc => mc.FluentMappings.AddFromAssemblyOf<BlogPostMap>()); fluentConfiguration.Mappings(mc => mc.FluentMappings.AddFromAssemblyOf<RoleMap>()); fluentConfiguration.Mappings(mc => mc.FluentMappings.AddFromAssemblyOf<SubscriberMap>()); }
public FluentConfiguration BuildMapping(FluentConfiguration configuration, Type type, string nameSpace) { configuration = configuration .Mappings(m => { m.AutoMappings.Add( AutoMap.Assemblies(Assembly.GetAssembly(type)) .UseOverridesFromAssembly(Assembly.GetAssembly(type)) .Conventions.AddAssembly(Assembly.GetAssembly(type)) .Where(t => t.Namespace != null && t.Namespace.StartsWith(nameSpace))); m.HbmMappings.AddFromAssembly(Assembly.GetAssembly(type)); // for stored procedures }); return configuration; }
public void AddAvailableMappings(FluentConfiguration fluentConfiguration) { foreach (var module in modulesRegistry.GetModules()) { try { var assembly = assemblyLoader.Load(module.ModuleDescriptor.AssemblyName); if (assembly != null) { fluentConfiguration = fluentConfiguration.Mappings(m => m.FluentMappings.AddFromAssembly(assembly)); } } catch (Exception ex) { Logger.ErrorFormat("Failed to load mappings from module {0} (assembly {1}).", ex, module.ModuleDescriptor.Name, module.ModuleDescriptor.AssemblyName); } } }
private static ISessionFactory CreateSessionFactory(Assembly contextAssembly, FluentConfiguration factoryConfig, AutoPersistenceModel autoPersistanceModel = null) { // Create mapping config factoryConfig.Mappings(m => { m.HbmMappings.AddFromAssembly(contextAssembly); m.FluentMappings.AddFromAssembly(contextAssembly); if (autoPersistanceModel != null) { m.AutoMappings.Add(autoPersistanceModel); } }); // Exemple of schemaExport and create // factoryConfig.ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true)); // Create factory var sessionFactory = factoryConfig.BuildSessionFactory(); return sessionFactory; }
static void SetDefaultConfig(FluentConfiguration config) { config.Mappings(c => { c.FluentMappings.Conventions.AddFromAssemblyOf<EnumConvention>(); var hbmXmlPath = Path.Combine(PathHelper.AppDataPath, "hbmXml"); DirectoryHelper.CreateIfNotExists(hbmXmlPath); c.FluentMappings.AddFromAssembly(_entityMapAssembly).ExportTo(hbmXmlPath); c.FluentMappings.Conventions.Add(DefaultLazy.Never()); c.FluentMappings.Conventions.Add( ConventionBuilder.HasMany.Always(x => { x.Fetch.Join(); }), ConventionBuilder.HasManyToMany.Always(x => { x.Fetch.Join(); }), ConventionBuilder.Reference.Always(x => { x.ReadOnly(); x.Fetch.Join(); x.Nullable(); x.NotFound.Ignore(); })); }); config.Cache(x => x.ProviderClass<NoCacheProvider>()); }
public static void Configure(FluentConfiguration cfg) { cfg.Mappings(x => x.FluentMappings.AddFromAssemblyOf<FileReferenceMap>()); }
private void InitMapping(FluentConfiguration fluentConfiguration) { fluentConfiguration.Mappings( x => { x.AutoMappings.Add(Generate()); #if DEBUG x.AutoMappings.ExportTo(@"D:\Temp"); #endif }); }
public static void Load() { _config = Fluently.Configure(); if (Manager.Settings.Driver == Settings.DbDriver.Sqlite) { var dbfile = Path.Combine(Manager.Settings.BasePath, Manager.Settings.SqliteFile); var basepath = Path.GetDirectoryName(dbfile); if (basepath != null && !Directory.Exists(basepath)) { try { Directory.CreateDirectory(basepath); } catch (Exception ex) { Logger.Log(String.Format("Could not create directory {0}: {1}", basepath, ex.Message), Logger.LogType.Error, typeof (SessionFactory)); } } Logger.Log(String.Format("Opening Database {0}", dbfile), Logger.LogType.Info, typeof (SessionFactory)); var sqlcfg = SQLiteConfiguration.Standard.UsingFile(dbfile); //sqlcfg.ShowSql(); //sqlcfg.FormatSql(); _config.Database(sqlcfg); } if (Manager.Settings.Driver == Settings.DbDriver.Mysql) { var sqlcfg = MySQLConfiguration.Standard.ConnectionString( String.Format( "Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};", Manager.Settings.MysqlHost, Manager.Settings.MysqlPort, Manager.Settings.MysqlDatabase, Manager.Settings.MysqlUser, Manager.Settings.MysqlPassword )); sqlcfg.Dialect<MySQL55InnoDBDialect>(); //sqlcfg.ShowSql(); //sqlcfg.FormatSql(); _config.Database(sqlcfg); } _config.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Vehicle>()); _factory = _config.BuildSessionFactory(); #if DEBUG //BuildSchema(); #endif }
public void AddAvailableMappings(FluentConfiguration fluentConfiguration) { fluentConfiguration.Mappings(mc => mc.FluentMappings.AddFromAssemblyOf<AuthorMap>()); fluentConfiguration.Mappings(mc => mc.FluentMappings.AddFromAssemblyOf<UserMap>()); fluentConfiguration.Mappings(mc => mc.FluentMappings.AddFromAssemblyOf<MediaMap>()); }
private void InitMapping(FluentConfiguration fluentConfiguration) { fluentConfiguration.Mappings( x => { x.AutoMappings.Add(PersistenceModelGenerator.Generate(new string[] {"NHibernateTest.exe"}, new string[] { "NHibernateTest.exe" })); x.FluentMappings.Add<IsDeletedFilter>(); x.AutoMappings.ExportTo(@"D:\Temp"); }); //fluentConfiguration.Mappings(m => m.FluentMappings.Add<ClassesMap>()); //fluentConfiguration.Mappings(m => m.FluentMappings.Add<StudentMap>()); //fluentConfiguration.Mappings(m => m.FluentMappings.Add<CourseMap>()); }
public static void Configure(FluentConfiguration cfg) { cfg.Mappings(x => x.FluentMappings.AddFromAssemblyOf<UserMap>()); new UserMapper(cfg.BuildConfiguration(), typeof(User)).Map(); }
protected override FluentConfiguration InnerConfiguration(FluentConfiguration cfg) { if (this.AutomappingConfigurer == null) return cfg; var autoMappingMetadataCollection = AutomappingConfigurer.GetAutomappingMetadata(); var persistenceAssemblies = autoMappingMetadataCollection .Select(metadata => Assembly.LoadFrom(metadata.AssemblyName)); return cfg.Mappings( m => m.AutoMappings.Add( AutoMap.Assemblies(new AutomappingConfigurationFilter(), persistenceAssemblies) .Conventions .Setup(c => { //c.Add(PrimaryKey.Name.Is(x => "Id")); c.Add(ForeignKey.Format((x, t) => t.Name + "Id")); c.Add(DefaultLazy.Always()); c.AddFromAssemblyOf<TablePluralizationConvention>(); }))); }
private void AddMappingToConfig(FluentConfiguration config) { config.Mappings(map => map.AutoMappings.Add(AutoMap.AssemblyOf<Person>(new AutomappingConfiguration()).Conventions.Add(DefaultCascade.All())) .Add(AutoMap.AssemblyOf<Wish>(new AutomappingConfiguration())) .Add(AutoMap.AssemblyOf<User>(new AutomappingConfiguration()))); }