Пример #1
0
        private static void CreateMappings(MappingConfiguration mappingConfiguration)
        {
            var assembly = (typeof (CarMap).Assembly);

            mappingConfiguration.FluentMappings.AddFromAssembly(assembly);
            mappingConfiguration.HbmMappings.AddFromAssembly(assembly);
        }
Пример #2
0
 private static void AddTablePerConcreteClassMappings(MappingConfiguration conf)
 {
     conf.FluentMappings.Add<PageOfBob.Comparison.NH.Mapping.TablePerConcreteClass.UserMapping>();
     conf.FluentMappings.Add<PageOfBob.Comparison.NH.Mapping.TablePerConcreteClass.ThingMapping>();
     conf.FluentMappings.Add<PageOfBob.Comparison.NH.Mapping.TablePerConcreteClass.EventMapping>();
     conf.FluentMappings.Add<PageOfBob.Comparison.NH.Mapping.TablePerConcreteClass.WorkMapping>();
 }
 private static void StudentMappings(MappingConfiguration m)
 {
     m.FluentMappings
      .Add<StudentMap>().Add<StudentXrefMap>()
      .Add<MarkMap>().Add<MarkXrefMap>()
      .Add<StudentTypeMap>();
 }
Пример #4
0
 public void Apply(MappingConfiguration configuration)
 {
     var conventions = configuration.FluentMappings.Conventions;
     conventions.Add(ConventionBuilder
                         .Class
                         .Always(x => x.Table(Inflector.Inflector.Pluralize(x.EntityType.Name).Escape())));
 }
Пример #5
0
        /// <summary>
        /// Vordefinieren von Konventionen für die Mappings.
        /// </summary>
        public void Apply(MappingConfiguration configuration)
        {
            var conventions = configuration.FluentMappings.Conventions;

            conventions.Add(ConventionBuilder
                                .Class
                                .Always(x => x.Table(Inflector.Net.Inflector.Pluralize(x.EntityType.Name).Escape())));

            /* Kann man machen, muss man aber nicht...
            conventions.Add(ConventionBuilder
                                .Id
                                .Always(x => x.Column(String.Format("{0}ID", x.EntityType.Name))));

            conventions.Add(ConventionBuilder.Reference.Always(x =>
                {
                    x.Column(String.Format("{0}ID", x.Property.Name));
                    x.ForeignKey(String.Format("FK_{0}To{1}", x.EntityType.Name, x.Property.Name));
                }));

            conventions.Add(ConventionBuilder.HasMany.Always(x =>
                {
                    x.Key.Column(String.Format("{0}ID", x.Key.EntityType.Name));
                    x.Key.ForeignKey(String.Format("FK_{0}To{1}",
                                                   x.Relationship.StringIdentifierForModel,
                                                   x.Relationship.EntityType.Name));
                }));
            */

            conventions.Add(ConventionBuilder.Property.Always(x => x.Column(x.Property.Name)));

            conventions.Add(DefaultLazy.Always());
        }
Пример #6
0
 private static void SocialMappings(MappingConfiguration m)
 {
     m.FluentMappings
      .Add<ProfileMap>().Add<ProfileXrefMap>()
      .Add<AddressMap>().Add<AddressXrefMap>()
      .Add<CountryMap>();
 }
Пример #7
0
 public void Map(MappingConfiguration m)
 {
     var mapper = new AutomaticMapper(m);
     mapper.LoadInterfaceMappingsFromAssemblyOf<AutoMaps>();
     MapRootEntities(mapper);
     m.HbmMappings.AddFromAssemblyOf<AutoMaps>();
 }
 private void Map(MappingConfiguration mapping)
 {
     foreach (var mappingConfig in _maps)
     {
         mappingConfig.Map(mapping);
     }
 }
Пример #9
0
 /// <summary>
 /// 
 /// </summary>
 private static void Mapper(MappingConfiguration config)
 {
     config
     .FluentMappings
     .AddFromAssemblyOf<DomainEntity>()
     ;
 }
Пример #10
0
        public override void ContributeMappings(Configuration configuration)
        {
            Arg.NotNull("configuration", configuration);

            MappingConfiguration mappingConfiguration = new MappingConfiguration();
            ContributeMappings(mappingConfiguration);
            mappingConfiguration.Apply(configuration);
        }
Пример #11
0
 public void Configure(MappingConfiguration config, Action<IConventionFinder> defaultConventions)
 {
     var model = AutoMap.Assembly(GetMappingAssembly());
     model = FilterModels(model);
     model.Conventions.Setup(FilterConventions(defaultConventions));
     config.AutoMappings.Add(model);
     config.AutoMappings.ExportTo(@"c:\Projects");
 }
Пример #12
0
 private static void AddTablePerHierarchyMappings(MappingConfiguration conf)
 {
     conf.FluentMappings.Add<PageOfBob.Comparison.NH.Mapping.TablePerHierachy.BaseObjectMapping>();
     conf.FluentMappings.Add<PageOfBob.Comparison.NH.Mapping.TablePerHierachy.UserMapping>();
     conf.FluentMappings.Add<PageOfBob.Comparison.NH.Mapping.TablePerHierachy.ThingMapping>();
     conf.FluentMappings.Add<PageOfBob.Comparison.NH.Mapping.TablePerHierachy.EventMapping>();
     conf.FluentMappings.Add<PageOfBob.Comparison.NH.Mapping.TablePerHierachy.WorkMapping>();
 }
 private static void AddFluentMappings(MappingConfiguration cfg)
 {
     var assemblies = AppDomain.CurrentDomain.GetAssemblies();
     foreach (Assembly assembly in assemblies)
     {
         cfg.FluentMappings.AddFromAssembly(assembly);
     }
 }
Пример #14
0
 public static void Map(MappingConfiguration mappingConfiguration)
 {
     mappingConfiguration.AutoMappings.Add(AutoMap
                                             .AssemblyOf<User>()
                                             .UseOverridesFromAssemblyOf<User>()
                                             .Conventions.AddFromAssemblyOf<User>()
                                             .Where(t => typeof(IEntity).IsAssignableFrom(t))
         );
 }
Пример #15
0
 private static void AddMappings(MappingConfiguration cfg)
 {
     cfg.FluentMappings.AddFromAssemblyOf<CountryMap>()
         .Conventions.Add<PluralClassConvention>()
         .Conventions.Add<UnderscorePropertyConvention>()
         .Conventions.Add<SqlServer2008GeographyTypeConvention>();
         // We're using geography, you can also use geometry
         //.Add<SqlServer2008GeometryTypeConvention>()
 }
Пример #16
0
 public void Apply(MappingConfiguration configuration)
 {
     var conventions = configuration.FluentMappings.Conventions;
     //conventions.Add(ConventionBuilder
     //                    .Class.Always(
     //                        x => x.Table(Inflector.Net.Inflector.Pluralize(x.EntityType.Name).Escape())));
     conventions.Add(ConventionBuilder.Property.Always(x => x.Column(x.Property.Name)));
     conventions.Add(DefaultLazy.Always());
 }
Пример #17
0
 void DiscoverClassMapsAndAddAssemblies(ITypeDiscoverer typeDiscoverer, MappingConfiguration mappings)
 {
     var assemblies = typeDiscoverer.FindMultiple(typeof(IMappingProvider)).Select(t => t.Assembly).Distinct();
     foreach (var assembly in assemblies)
     {
         mappings.FluentMappings.AddFromAssembly(assembly).Conventions.Add(DefaultLazy.Never(), AutoImport.Never());
         mappings.HbmMappings.AddFromAssembly(assembly);
     }
         
 }
        public void CreateMappingConfiguration()
        {
            cfg = new Configuration();

            SQLiteConfiguration.Standard
                .InMemory()
                .ConfigureProperties(cfg);

            mapping = new MappingConfiguration();
        }
Пример #19
0
 static void AddAssemblies(
     IEnumerable<Assembly> assembliesWithFluentMappings,
     IEnumerable<Assembly> assembliesWithHbmMappings,
     MappingConfiguration mappings)
 {
     assembliesWithFluentMappings.ForEach(
         a => mappings.FluentMappings.AddFromAssembly(a).Conventions.Add(DefaultLazy.Never(), AutoImport.Never()));
     assembliesWithHbmMappings.ForEach(
         a => mappings.HbmMappings.AddFromAssembly(a));
 }
        public void CreateMappingConfiguration()
        {
            logger = Stub<IDiagnosticLogger>.Create();
            cfg = new Configuration();

            SQLiteConfiguration.Standard
                .InMemory()
                .ConfigureProperties(cfg);

            mapping = new MappingConfiguration(logger);
        }
        private void ConfigureMapping(string sessionAlias, MappingConfiguration mappingConfiguration)
        {
            hbmMappingRegisterer.Apply(sessionAlias, mappingConfiguration.HbmMappings);

            foreach (IAutoPersistenceModelProvider autoPersistenceModelProvider in autoPersistenceModelProviders)
            {
                AutoPersistenceModel autoPersistenceModel = autoPersistenceModelProvider.GetAutoPersistenceModel(assemblyProvider, sessionAlias);
                autoPersistenceModel.Conventions.Setup(conventionFinder => conventionApplier.Apply(sessionAlias, conventionFinder));
                mappingConfiguration.AutoMappings.Add(autoPersistenceModel);
            }
            mappingConfiguration.MergeMappings();
        }
        private static void CreateMappings(MappingConfiguration mappingConfiguration)
        {
            var assembly = typeof(EntityMap<Entity>).Assembly;

            mappingConfiguration.FluentMappings.AddFromAssembly(assembly);
            mappingConfiguration.HbmMappings.AddFromAssembly(assembly);
            mappingConfiguration.FluentMappings.Conventions.AddFromAssemblyOf<PrimaryKeyConvention>();
            mappingConfiguration.FluentMappings.Conventions.AddFromAssemblyOf<HasManyConvention>();
            mappingConfiguration.FluentMappings.Conventions.AddFromAssemblyOf<HasOneConvention>();
            mappingConfiguration.FluentMappings.Conventions.AddFromAssemblyOf<JoinedSubclassConvention>();
            mappingConfiguration.FluentMappings.Conventions.AddFromAssemblyOf<ReferencesConvention>();
        }
        /// <summary>
        /// Configures the given mapping
        /// </summary>
        /// <param name="m"></param>
        public void Run(MappingConfiguration m)
        {
            m.HbmMappings
                .AddFromAssemblyOf<AutoPersistenceModelGenerator>();
            m.FluentMappings
                .AddFromAssemblyOf<AutoPersistenceModelGenerator>()
                .Conventions.Setup(GetConventions);
            m.AutoMappings
                .Add(Generate());

            //m.AutoMappings.ExportTo(@"D:\_Development\JiscCollections\mappings");
            m.FluentMappings.ExportTo(@"C:\_Development\FootyLinks\Database\Mappings");
        }
        /// <summary>
        ///  Mapeia dinamicamente pela referencia do assembly
        /// </summary>
        /// <param name="config"></param>
        public static void MappingsAssembly(MappingConfiguration config)
        {
            string topNamespace = "Axis.Domain";
            Assembly assemblyNamespace = Assembly.Load(topNamespace);

            Type[] mappingList = Assembly.GetExecutingAssembly()
                                                .GetTypes()
                                                .Where(t => String.Equals(t.Namespace, topNamespace + ".Mapping", StringComparison.Ordinal)).ToArray();
            foreach (var item in mappingList)
            {
                config.FluentMappings.Add(assemblyNamespace.GetType(topNamespace + ".Mapping." + item.Name, true, true));
            }
        }
        public static void ConfigureMappings(MappingConfiguration mappingConfiguration, params IMappingConfigurationContributor[] configurationContributors)
        {
            mappingConfiguration.FluentMappings
                .Conventions.Add(
                    ForeignKey.EndsWith("Id"),
                    PrimaryKey.Name.Is(x => x.EntityType.Name + "Id"),
                    DefaultCascade.None());

            foreach (var configurationContributor in configurationContributors)
            {
                configurationContributor.ConfigureMappings(mappingConfiguration);
            }
        }
Пример #26
0
        private void ConfigureMappings(MappingConfiguration config)
        {
            Database.Configuration.Mappings.ForEach(map => config.FluentMappings.AddFromAssembly(map));

            config.FluentMappings.Conventions.Add<EnumConvention>();
            config.FluentMappings.Conventions.Add<MonthConvention>();

            config.FluentMappings.Conventions.Add(
                DefaultLazy.Always(),
                DefaultCascade.None(),
                DynamicInsert.AlwaysTrue(),
                DynamicUpdate.AlwaysTrue());
        }
        private static void AddImportedFluentMappings(MappingConfiguration cfg)
        {
            cfg.FluentMappings.Conventions.Setup(
                x =>
                {
                    x.Add(new CustomForeignKeyConvention());
                });

            var mappings = ServiceLocator.Current.GetAllInstances<IMappedEntity>();
            foreach (IMappedEntity mapping in mappings)
            {
                cfg.FluentMappings.Add(mapping.GetType());
            }
        }
Пример #28
0
        public void Configure(MappingConfiguration mappingConfig)
        {
            var assemblies = Assembly.GetAssembly(typeof (Entity));
            var conventions = new IConvention[]
                                  {
                                      DefaultCascade.All(),
                                      ConventionBuilder.Id.Always(m => m.GeneratedBy.HiLo("1000")),
                                      ConventionBuilder.HasMany.Always(m => m.Inverse())
                                  };

            mappingConfig.AutoMappings.Add(
                AutoMap.Assemblies(new AutoMapConfig(), assemblies)
                    .Conventions.Add(conventions));
        }
Пример #29
0
        private static void BuildFluentMappingConfig(MappingConfiguration mappings)
        {
            //mappings.FluentMappings.AddFromAssemblyOf<EmployeeMap>();

            var autoCfg = new FluentAutoMappingConfiguration();
            var autoMappings = AutoMap.AssemblyOf<Employee>(autoCfg)
                .Conventions.AddFromAssemblyOf<CustomPrimaryKeyConvention>()
                .Override<Store>(map =>
                {
                    map.HasMany(x => x.Staff).Cascade.All();
                    map.HasManyToMany(x => x.Products).Cascade.All();
                })
                 ;

            mappings.AutoMappings.Add(autoMappings);
        }
Пример #30
0
 public void Configure(MappingConfiguration config)
 {
     config.AutoMappings.Add(AutoMap.Assembly(_assemblyToMap, new AutoMapperConventions(_namespaces)).Conventions.Add(
         new IConvention[]
         {
             ConventionBuilder.Class.Always(a => a.Table(GetTableName(a))),
             ConventionBuilder.Id.When(a => a.Expect(i => ((PropertyInfo)i.Property.MemberInfo).PropertyType == typeof(Guid)),
                                     c => c.GeneratedBy.Assigned()),
             ConventionBuilder.Id.When(a => a.Expect(i => ((PropertyInfo)i.Property.MemberInfo).PropertyType == typeof(int)),
                                     c => c.GeneratedBy.Identity()),
             ConventionBuilder.HasMany.When(a => a.Expect(i => i.Member.GetCustomAttributes(typeof(PwnsAttribute), false).Any()),
                                     c => c.Cascade.AllDeleteOrphan()),
             ConventionBuilder.HasMany.When(a => a.Expect(i => RequiresCustomPropertyName(i.EntityType)),
                                     c => c.Key.Column(GetCustomPropertyName(c.Relationship.EntityType))),
             ConventionBuilder.Reference.When(a => a.Expect(i => RequiresCustomPropertyName(i.EntityType)),
                                     c => c.Column(GetCustomPropertyName(c.EntityType)))
         }).UseOverridesFromAssembly(_overrideAssembly));
 }