public AutoPersistenceModel Generate()
 {
     var mappings = new AutoPersistenceModel();
     mappings.AddEntityAssembly(typeof(Site).Assembly).Where(GetAutoMappingFilter);
     //    mappings.Setup(GetSetup());
     mappings.IgnoreBase<Entity>();
     mappings.IgnoreBase(typeof(EntityWithTypedId<>));
     mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
     return mappings;
 }
        public AutoPersistenceModel Generate()
        {
            var mappings = new AutoPersistenceModel();

            mappings.AddEntityAssembly(typeof(TestEntity).Assembly).Where(this.GetAutoMappingFilter);
            mappings.Conventions.Setup(this.GetConventions());
            mappings.Setup(this.GetSetup());
            mappings.IgnoreBase <Entity>();
            mappings.IgnoreBase(typeof(EntityWithTypedId <>));
            mappings.UseOverridesFromAssemblyOf <AutoPersistenceModelGenerator>();
            return(mappings);
        }
        public AutoPersistenceModel Generate()
        {
            var mappings = new AutoPersistenceModel();

            mappings.AddEntityAssembly(typeof(Layout).Assembly).Where(GetAutoMappingFilter);
            mappings.Conventions.Setup(GetConventions());
            mappings.Setup(GetSetup());
            mappings.IgnoreBase <Entity>();
            mappings.IgnoreBase <BasicLocation>();
            mappings.IncludeBase <BasicUser>();
            //mappings.IncludeBase<RegisteredUser>();
            //mappings.IncludeBase<Contact>();
            mappings.IgnoreBase(typeof(EntityWithTypedId <>));
            mappings.UseOverridesFromAssemblyOf <AutoPersistenceModelGenerator>();

            return(mappings);
        }
Exemple #4
0
 public void Alter(AutoPersistenceModel model)
 {
     model.IgnoreBase(typeof(Entity <>));
     model.IgnoreBase(typeof(Entity));
     model.IgnoreBase(typeof(VersionedEntity <>));
     model.IgnoreBase(typeof(VersionedEntity));
     model.IgnoreBase(typeof(VersionedEntityWithUser <>));
     model.IgnoreBase(typeof(VersionedEntityWithUser <,>));
     model.IgnoreBase(typeof(Document <, , ,>));
     model.IgnoreBase(typeof(DocumentVersion <, , ,>));
 }
        public AutoPersistenceModel Generate()
        {
            var mappings = new AutoPersistenceModel();
            mappings.AddEntityAssembly(typeof(Soul).Assembly).Where(GetAutoMappingFilter);
            mappings.Conventions.Setup(GetConventions());
            mappings.Setup(GetSetup());
            mappings.IgnoreBase<Entity>();
            mappings.IgnoreBase(typeof(EntityWithTypedId<>));
            mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();

            // Membershipprovider Automappings
            mappings.AddEntityAssembly(typeof(Shaml.Membership.Core.User).Assembly).Where(GetAutoMappingFilter);
            mappings.Override<Shaml.Membership.Core.User>(map => Shaml.Membership.Data.Overrides.UserOverride(map));
            mappings.Override<Shaml.Membership.Core.Role>(map => Shaml.Membership.Data.Overrides.RoleOverride(map));
            mappings.Override<Shaml.Membership.Core.ProfileData>(map => Shaml.Membership.Data.Overrides.ProfileDataOverride(map));
            mappings.Override<Shaml.Membership.Core.Session>(map => Shaml.Membership.Data.Overrides.SessionOverride(map));

            return mappings;
        }
        public AutoPersistenceModel Generate()
        {
            var mappings = new AutoPersistenceModel();

            mappings = AutoMap.AssemblyOf<Domain.Entity>();
            mappings.Where(GetAutoMappingFilter);
            mappings.Conventions.Setup(GetConventions());
            mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
            mappings.Setup(GetSetup());
            mappings.OverrideAll(x => x.IgnoreProperties(z => z.PropertyType.IsSubclassOf(typeof(Enumeration))));

            mappings.IgnoreBase<Domain.Entity>();
            mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();

            return mappings;
        }
Exemple #7
0
        private ISessionFactory CreateSessionFactory()
        {
            Configuration initialConfiguration = this.GetConfiguration()
                                                 .OrFail(nameof(this.GetConfiguration) + "()");

            FluentConfiguration fluentConfiguration = Fluently.Configure(initialConfiguration)
                                                      //.CurrentSessionContext<CurrentSessionContext>()
                                                      //.Mappings(
                                                      //    m => m.FluentMappings
                                                      //          .Add<GusContractorSnapshot.Map>()
                                                      //          .Add<GusContractorLog.Map>()
                                                      //)
            ;

            Library[] libraries = this.Librarian.OrFail(nameof(this.Librarian))
                                  .GetLibraries();

            IConvention[] conventions = this.GetConventions()
                                        .OrFail(nameof(this.Conventions));

            Type[] entities = this.GetEntities()
                              .ToArray();

            var automappingConfiguration = new AutomappingConfiguration(entities);

            foreach (Library library in libraries)
            {
                Assembly             assembly         = library.GetAssembly();
                AutoPersistenceModel assemblyMappings = AutoMap.Assembly(assembly, automappingConfiguration);
                assemblyMappings.Conventions.Add(conventions);
                assemblyMappings.UseOverridesFromAssembly(assembly);
                assemblyMappings.IgnoreBase <Entity>();

                fluentConfiguration.Mappings(m =>
                {
                    m.FluentMappings.Conventions.Add(conventions);
                    m.AutoMappings.Add(assemblyMappings);
                });
            }

            this.configuration = fluentConfiguration.BuildConfiguration();
            return(fluentConfiguration.BuildSessionFactory());
        }
        private static Configuration BuildConfiguration(
            string connectionString)
        {
            Configuration configuration = new Configuration();


            AutoPersistenceModel model = AutoMap.AssemblyOf <Entity>();

            model.IgnoreBase <Entity>();
            model.Conventions.Add <TableNameConvention>();
            model.Conventions.Add <IdConvention>();
            model.Conventions.Add <ReferenceConvention>();

#if DEBUG
            try
            {
                // Writes into specific folder
                string folder = Path.Combine(@"c:\MyProjectMapping", "Mapping");
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }

                model.WriteMappingsTo(folder);
            }
            catch { }
#endif
            model.Configure(configuration);

            if (!string.IsNullOrEmpty(connectionString))
            {
                configuration.SetProperty("connection.connection_string", connectionString);
            }

            return(configuration);
        }
Exemple #9
0
 private void SetAutoPersistenceModelDefaults(AutoPersistenceModel mappings)
 {
     mappings.Conventions.Setup(GetConventions());
     mappings.IgnoreBase <DomainObject>();
     mappings.IgnoreBase(typeof(DomainObjectWithTypedId <>));
 }