当前位置: 首页>>代码示例>>C#>>正文


C# AutoPersistenceModel.AddEntityAssembly方法代码示例

本文整理汇总了C#中AutoPersistenceModel.AddEntityAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# AutoPersistenceModel.AddEntityAssembly方法的具体用法?C# AutoPersistenceModel.AddEntityAssembly怎么用?C# AutoPersistenceModel.AddEntityAssembly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AutoPersistenceModel的用法示例。


在下文中一共展示了AutoPersistenceModel.AddEntityAssembly方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SagaPersistenceModel

        public static AutoPersistenceModel SagaPersistenceModel(IEnumerable<Type> typesToScan)
        {
            var sagaEntites = typesToScan.Where(t => typeof(ISagaEntity).IsAssignableFrom(t) && !t.IsInterface);

            var model = new AutoPersistenceModel();

            model.Conventions.AddFromAssemblyOf<IdShouldBeAssignedConvention>();

            var entityTypes = GetTypesThatShouldBeAutoMapped(sagaEntites,typesToScan);

            var assembliesContainingSagas = sagaEntites.Select(t => t.Assembly).Distinct();

            foreach (var assembly in assembliesContainingSagas)
                model.AddEntityAssembly(assembly)
                    .Where(t => entityTypes.Contains(t));

            var componentTypes = GetTypesThatShouldBeMappedAsComponents(sagaEntites);

            model.Setup(s =>
                          {
                              s.IsComponentType =
                                  type => componentTypes.Contains(type);
                          });
            return model;
        }
开发者ID:togakangaroo,项目名称:NServiceBus,代码行数:25,代码来源:Create.cs

示例2: Generate

 public AutoPersistenceModel Generate()
 {
     var mappings = new AutoPersistenceModel();
     mappings.AddEntityAssembly(typeof (Class1).Assembly).Where(GetAutoMappingFilter);
     mappings.Conventions.Setup(GetConventions());
     mappings.Setup(GetSetup());
     mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
     return mappings;
 }
开发者ID:jhollingworth,项目名称:Hedgehog,代码行数:9,代码来源:AutoPersistenceModelGenerator.cs

示例3: Generate

        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;
        }
开发者ID:sztupy,项目名称:CodeChirp,代码行数:19,代码来源:AutoPersistenceModelGenerator.cs

示例4: Generate

 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;
 }
开发者ID:fudder,项目名称:cs493,代码行数:10,代码来源:AutoPersistenceModelGenerator.cs

示例5: Generate

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

            mappings.AddEntityAssembly(typeof (Class1).Assembly).Where(GetAutoMappingFilter);
            mappings.Conventions.Setup(GetConventions());
            mappings.Setup(GetSetup());
            mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();

            mappings.Override<Idea>(i => i.Map(m => m.Text).CustomSqlType("TEXT"));
            mappings.Override<Comment>(c => c.Map(m => m.Text).CustomSqlType("TEXT"));

            return mappings;
        }
开发者ID:jhollingworth,项目名称:ideas,代码行数:14,代码来源:AutoPersistenceModelGenerator.cs

示例6: Generate

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

            mappings
                .AddEntityAssembly(typeof(Player).Assembly)
                .UseOverridesFromAssembly(typeof(AutoPersistenceModelGenerator).Assembly)
                .Where(GetAutoMappingFilter);
                //.Setup(GetSetup())
                //.Conventions.Setup(GetConventions);

            MapEnums(mappings);

            return mappings;
        }
开发者ID:MikeHook,项目名称:FootyLinks,代码行数:15,代码来源:AutoPersistenceModelGenerator.cs

示例7: GetAutoMappingSettings

        private static AutoPersistenceModel GetAutoMappingSettings( Assembly entitiesAssembly, Assembly mappingsOverridesAssembly )
        {
            var persistenceModel = new AutoPersistenceModel();
            persistenceModel.AddEntityAssembly( entitiesAssembly ).Where( x => x.BaseType.Name == "BaseEntity" );
            persistenceModel.UseOverridesFromAssembly( mappingsOverridesAssembly );
            persistenceModel.Conventions.Add(
                PrimaryKey.Name.Is( x => "Id" ),
                ConventionBuilder.Id.Always( x => x.GeneratedBy.Identity() ),
                ConventionBuilder.Property.Always( x => x.Not.Nullable() ),
                ConventionBuilder.Property.When( expectation =>
                    expectation.Expect( propertyInspector => propertyInspector.Property.PropertyType == typeof( string ) ),
                    instance => instance.Length( 256 ) ),
                ConventionBuilder.Reference.Always( x => x.Not.Nullable() ),
                ForeignKey.EndsWith( "Id" )
            );

            return persistenceModel;
        }
开发者ID:jrote1,项目名称:PseudoCQRS-bootstrap,代码行数:18,代码来源:FluentNHibernateMappingsInitializer.cs

示例8: GetSessionFactory

        ISessionFactory GetSessionFactory()
        {
            var autoPersistenceModel = new AutoPersistenceModel();

            autoPersistenceModel
                .AddEntityAssembly(GetType().Assembly)
                .Where(t => t.Namespace.StartsWith("NHibernateWebPersistenceExample.Models"));

            ISessionFactory sessionFactory = Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008
                              .ConnectionString(c =>
                                                c.Is(
                                                    @"Data Source=.\SQLEXPRESS;Initial Catalog=Example;Integrated Security=True;Pooling=False"))
                              .ShowSql())
                .Mappings(m => m.AutoMappings.Add(autoPersistenceModel))
                .ExposeConfiguration(innerConfiguration =>
                                     innerConfiguration.SetProperty("current_session_context_class", "web"))
                .BuildSessionFactory();

            return sessionFactory;
        }
开发者ID:bsommardahl,项目名称:ncommons,代码行数:21,代码来源:WebRegistry.cs

示例9: AutoMap

 /// <summary>
 /// Configures FluentNHibernate to map the domain types used in PerfTest.
 /// </summary>
 public static AutoPersistenceModel AutoMap(AutoPersistenceModel model)
 {
     model
         .AddEntityAssembly(typeof(TestSuiteResult).Assembly)
         .Override<TestSuiteResult>(map =>
         {
             map.HasMany(x => x.SystemInfoList).AsSet().Inverse().Cascade.All().Not.LazyLoad();
             map.HasMany(x => x.TestResultList).AsSet().Inverse().Cascade.All().Not.LazyLoad();
         })
         .Override<SystemInfo>(map =>
         {
             map.References(x => x.TestSuiteResult, "TestSuiteResultId").Cascade.None().Not.Nullable();
         })
         .Override<TestResult>(map =>
         {
             map.HasMany(x => x.TimingDataList).AsSet().Inverse().Cascade.All().Not.LazyLoad();
             map.References(x => x.TestSuiteResult, "TestSuiteResultID").Cascade.None().Not.Nullable();
         })
         .Override<TimingData>(map =>
         {
             map.References(x => x.TestResult, "TestResultID").Cascade.None().Not.Nullable();
         });
     return model;
 }
开发者ID:shj333,项目名称:dotnet_utils,代码行数:27,代码来源:PerfTestFluentConfig.cs

示例10: SetupAutoMapperForEntities

        public static void SetupAutoMapperForEntities(IDependencyResolver dependencyResolver, params Assembly[] assemblies)
        {
            var database = dependencyResolver.Resolve<IPersistenceConfigurer>();
            var config = Fluently.Configure().Database(database);
            var stringPropertyconvention = ConventionBuilder.Property.When(x => x.Expect(p => p.Property.PropertyType == typeof (string)), a => a.Length(255));

            var cacheConvention = ConventionBuilder.Class.Always(c => c.Cache.ReadWrite());

            var collectionsConventionMany = ConventionBuilder.HasMany.When(
                x => x.Expect(p => !(p.Member is DummyPropertyInfo)),
                instance => { instance.Cascade.SaveUpdate(); instance.Cache.ReadWrite(); });

            var collectionsConventionManyToMany = ConventionBuilder.HasManyToMany.When(
                x => x.Expect(p => !(p.Member is DummyPropertyInfo)),
                instance => { instance.Cascade.SaveUpdate(); instance.Cache.ReadWrite(); });
            var lazyConvention = ConventionBuilder.Reference.Always(c => c.LazyLoad());

            IEnumerable<Assembly> ass;
            if (assemblies == null || assemblies.Length == 0)
            {
                ass = AppDomain.CurrentDomain.GetAssemblies().Where(
                    a => !a.FullName.StartsWith("System.") &&
                         !a.FullName.StartsWith("Microsoft.") &&
                         !a.FullName.Contains("mscorlib") &&
                         a != typeof(ISession).Assembly &&
                         a != typeof(AutoMap).Assembly
               );
            }
            else
            {
                ass = assemblies;
            }

            var autoPersistenceModel = new AutoPersistenceModel()
                .Conventions.Add(cacheConvention, collectionsConventionMany, collectionsConventionManyToMany, stringPropertyconvention, lazyConvention)
                .IgnoreBase(typeof (BaseEntity<>))
                .IgnoreBase(typeof (IBaseEntity));

            foreach (var assembly in ass)
            {
                try
                {
                    assembly.GetExportedTypes();
                }
                catch (NotSupportedException)
                {
                    continue;//cannot do dynamic assemblies
                }
                if (assembly != null)
                {
                    Assembly automapper = assembly;

                    config.Mappings(m => m.HbmMappings.AddFromAssembly(automapper));
                    autoPersistenceModel
                        .AddEntityAssembly(automapper)
                        .Conventions.AddAssembly(automapper)
                        .Alterations(alterations => alterations.AddFromAssembly(automapper))
                        .Alterations(collection => collection.Add(new AutoMappingOverrideAlteration(automapper))) //same as: UseOverridesFromAssemblyOf<Tentity>()
                        .Where(t => typeof (IBaseEntity).IsAssignableFrom(t));

                    // MORE Evil hack, since adding to the Alterations does NOT work.
                    //new AutoMappingOverrideAlteration(automapper).Alter(autoPersistenceModel);
                }
            }

            // Evil hack, since adding to the Alterations does NOT work.
            //foreach (var overrideAssembly in ass)
            //{
            //    new AutoMappingOverrideAlteration(overrideAssembly).Alter(autoPersistenceModel);
            //}

            config.Mappings(m => m.AutoMappings.Add(autoPersistenceModel)
            #if DEBUG
            .ExportTo(@"C:\temp\")
            #endif
            );

            var nhconfig = config.BuildConfiguration();
            var sessionFactory = config.BuildSessionFactory();

            dependencyResolver.RegisterInstance<Configuration>(nhconfig);
            dependencyResolver.RegisterInstance<ISessionFactory>(sessionFactory);

            new SchemaUpdate(nhconfig).Execute(true, true);
        }
开发者ID:JoeyCyril,项目名称:BoC,代码行数:85,代码来源:NHibernateConfigHelper.cs

示例11: RegisterEntitiesAssembly

        private void RegisterEntitiesAssembly(Configuration configuration, Assembly assembly)
        {
            var model = new AutoPersistenceModel()
                .WithSetup(s => s.IsBaseType = (type => type == typeof (BaseEntity) || type == typeof (BaseOrderedEntity)
                                                        || type == typeof (BaseVersionedEntity) || type == typeof (BaseVersionedAndOrderedEntity)))
                .ConventionDiscovery.Setup(c =>
                                           	{
                                           		c.Add<FluentNHibernate.Conventions.Defaults.PrimaryKeyConvention>();
                                           		c.Add<ForeignKeyConvention>();
                                           		c.Add<TableNameConvention>();
                                           		c.Add<ManyToManyTableConvention>();
                                           	}
                );

            model
                .AddEntityAssembly(assembly)
                .Where(entity => entity.IsAbstract == false &&
                                 entity.GetInterface("IEntity") != null)
                .Configure(configuration);
        }
开发者ID:pollingj,项目名称:Membrane-CMS,代码行数:20,代码来源:MonoRailNHibernateHttpApplication+.cs


注:本文中的AutoPersistenceModel.AddEntityAssembly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。