private static HbmMapping GetMappings(IEnumerable <Assembly> mappingsAssemblies) { //Using the built-in auto-mapper var mapper = new ConventionModelMapper(); DefineBaseClass(mapper); var allEntities = new List <Type>(); foreach (var mappingsAssembly in mappingsAssemblies) { allEntities.AddRange(mappingsAssembly.GetTypes().Where( t => BaseEntityToIgnore.IsAssignableFrom(t) && t != BaseEntityToIgnore && !t.IsInterface ).ToList()); } mapper.AddAllManyToManyRelations(allEntities); mapper.ApplyNamingConventions(); if (MapAllEnumsToStrings) { mapper.MapAllEnumsToStrings(); } if (AutoMappingOverride != null) { AutoMappingOverride(mapper); } OverrideByClassMapping(mapper, mappingsAssemblies); var mapping = mapper.CompileMappingFor(allEntities); //ShowOutputXmlMappings(mapping); return(mapping); }
private static HbmMapping GetMappings(Type baseEntityToIgnore, Assembly mappingsAssembly, string mappingsNamespace, bool mapAllEnumsToStrings, Action <ModelMapper> autoMappingOverride, bool showLogs, string outputXmlMappingsFile) { //Using the built-in auto-mapper var mapper = new ConventionModelMapper(); DefineBaseClass(mapper, new[] { baseEntityToIgnore }); var allEntities = mappingsAssembly.GetTypes().Where(t => t.Namespace == mappingsNamespace).ToList(); mapper.AddAllManyToManyRelations(allEntities); mapper.ApplyNamingConventions(); if (mapAllEnumsToStrings) { mapper.MapAllEnumsToStrings(); } if (autoMappingOverride != null) { autoMappingOverride(mapper); } var mapping = mapper.CompileMappingFor(allEntities); showOutputXmlMappings(mapping, showLogs, outputXmlMappingsFile); return(mapping); }
private HbmMapping getMappings() { //Using the built-in auto-mapper var mapper = new ConventionModelMapper(); var allEntities = MappingsAssembly.GetTypes().Where(t => t.Namespace == MappingsNamespace).ToList(); mapper.AddAllManyToManyRelations(allEntities); mapper.ApplyNamingConventions(); if (AutoMappingOverride != null) { AutoMappingOverride(mapper); } var mapping = mapper.CompileMappingFor(allEntities); showOutputXmlMappings(mapping); return(mapping); }
private HbmMapping GetHbmMappings() { var mapper = new ConventionModelMapper(); var mappings = MappingAssembly.GetExportedTypes().Where(MappingTypeFinder).ToList(); mapper.AddMappings(mappings); mapper.ApplyNamingConventions(); if (AutoMappingOverride != null) { AutoMappingOverride(mapper); } var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities(); ShowOutputXmlMappings(mapping); return(mapping); }
public static Configuration Init(Configuration configuration, ISessionStorage storage, Type[] baseEntityToIgnore, Type[] allEntities, Action <ModelMapper> autoMappingOverride, bool showLogs = false) { InitStorage(storage); try { var mapper = new ConventionModelMapper(); DefineBaseClass(mapper, baseEntityToIgnore); mapper.AddAllManyToManyRelations(allEntities); mapper.ApplyNamingConventions(); mapper.MapAllEnumsToStrings(); if (autoMappingOverride != null) { autoMappingOverride(mapper); } var mapping = mapper.CompileMappingFor(allEntities); showOutputXmlMappings(mapping, showLogs, "mappings.xml"); configuration.AddDeserializedMapping(mapping, null); var sessionFactory = configuration.BuildSessionFactory(); return(AddConfiguration(DefaultFactoryKey, sessionFactory, configuration, string.Empty)); } catch { // If this NHibernate config throws an exception, null the Storage reference so // the config can be corrected without having to restart the web application. Storage = null; throw; } }
private HbmMapping GetMappings() { //Using the built-in auto-mapper var mapper = new ConventionModelMapper(); DefineBaseClass(mapper); var allEntities = MappingsAssemblies.SelectMany(a => a.GetTypes()).Where(t => t.Namespace == MappingsNamespace).ToList(); mapper.AddAllManyToManyRelations(allEntities); mapper.ApplyNamingConventions(); if (MapAllEnumsToStrings) { mapper.MapAllEnumsToStrings(); } if (AutoMappingOverride != null) { AutoMappingOverride(mapper); } var mapping = mapper.CompileMappingFor(allEntities); ShowOutputXmlMappings(mapping); return(mapping); }