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


C# ConventionModelMapper.IsEntity方法代码示例

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


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

示例1: DefineBaseClass

 private static void DefineBaseClass(ConventionModelMapper mapper, System.Type[] baseEntityToIgnore)
 {
     if (baseEntityToIgnore == null) return;
     mapper.IsEntity((type, declared) =>
         baseEntityToIgnore.Any(x => x.IsAssignableFrom(type)) &&
         !baseEntityToIgnore.Any(x => x == type) &&
         !type.IsInterface);
     mapper.IsRootEntity((type, declared) => baseEntityToIgnore.Any(x => x == type.BaseType));
 }
开发者ID:RichardPAsch,项目名称:PIMS,代码行数:9,代码来源:MappingHelper.cs

示例2: AddConventionalMapping

        static void AddConventionalMapping(Configuration cfg)
        {
            var modelMapper = new ConventionModelMapper();
            modelMapper.IsEntity((x, y) => x.IsClass == true && x.IsSealed == false && x.Namespace == typeof(Program).Namespace);
            modelMapper.BeforeMapClass += (x, y, z) => { z.Id(a => a.Generator(Generators.Identity)); z.Lazy(true); };
            modelMapper.BeforeMapManyToOne += (x, y, z) => { z.Lazy(LazyRelation.Proxy); z.NotNullable(true); };

            var mappings = modelMapper.CompileMappingFor(typeof(Program).Assembly.GetTypes().Where(x => x.IsPublic && x.IsSealed == false));

            cfg.AddMapping(mappings);
        }
开发者ID:rjperes,项目名称:NHPerformance,代码行数:11,代码来源:Program.cs

示例3: GetMappings

		protected override HbmMapping GetMappings()
		{
			var mapper = new ConventionModelMapper();
			System.Type baseEntityType = typeof (DomainObject);
			mapper.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && !baseEntityType.Equals(t));
			mapper.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType));
			mapper.Class<DomainObject>(r =>
			                           {
			                           	r.Version(x => x.EntityVersion, map => { });
			                           	r.Id(x => x.ID, map => map.Generator(Generators.Native));
			                           });
			mapper.Class<Class1>(r => { r.IdBag(x => x.Class2List, map => map.Inverse(true), rel => rel.ManyToMany()); });
			mapper.Class<Class2>(r => { r.IdBag<Class1>("_class1List", map => { }, rel => rel.ManyToMany()); });
			HbmMapping mappings = mapper.CompileMappingFor(new[] {typeof (Class1), typeof (Class2)});
			return mappings;
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:16,代码来源:Fixture.cs

示例4: WhenPropertyVersionFromBaseEntityThenFindItAsVersion

		public void WhenPropertyVersionFromBaseEntityThenFindItAsVersion()
		{
			var mapper = new ConventionModelMapper();
			var baseEntityType = typeof(BaseEntity);
			mapper.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && baseEntityType != t && !t.IsInterface);
			mapper.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType));
			mapper.Class<BaseEntity>(
				map =>
				{
					map.Id(x => x.Id, idmap => { });
					map.Version(x => x.Version, vm => { });
				});
			var hbmMapping = mapper.CompileMappingFor(new[] { typeof(Person) });

			var hbmClass = hbmMapping.RootClasses[0];
			var hbmVersion = hbmClass.Version;
			Assert.That(hbmVersion, Is.Not.Null);
			Assert.That(hbmVersion.name, Is.EqualTo("Version"));
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:19,代码来源:VersionOnBaseClassIntegrationTest.cs

示例5: CreateMappingConfiguration

        public static HbmMapping CreateMappingConfiguration()
        {
            var mapper = new ConventionModelMapper();

            var baseEntityType = typeof (Entity);
            mapper.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && baseEntityType != t && !t.IsInterface);
            mapper.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType));

            mapper.BeforeMapManyToOne += (insp, prop, map) => map.Column(prop.LocalMember.GetPropertyOrFieldType().Name + "Id");
            mapper.BeforeMapBag += (insp, prop, map) => map.Key(km => km.Column(prop.GetContainerEntity(insp).Name + "Id"));
            mapper.BeforeMapBag += (insp, prop, map) => map.Cascade(Cascade.All);

            mapper.Class<Album>(map => map.Id(x => x.AlbumId, m=> m.Generator(Generators.Identity)));
            mapper.Class<Artist>(map => map.Id(x => x.ArtistId, m => m.Generator(Generators.Identity)));

            var mapping = mapper.CompileMappingFor(baseEntityType.Assembly.GetExportedTypes());

            return mapping;
        }
开发者ID:mravinale,项目名称:simple-cqrs,代码行数:19,代码来源:EntitiesMapper.cs

示例6: Create

        public ISessionFactory Create()
        {
            var cfg = new Configuration();
            cfg.DataBaseIntegration(
                db =>
                    {
                        db.ConnectionString =
                            "Server=tcp:localhost;Database=DataSample;Trusted_Connection=true;Encrypt=False;";
                        db.Dialect<MsSql2008Dialect>();
                        db.BatchSize = 250;
                        db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                        db.SchemaAction = SchemaAutoAction.Update;
                    }).SessionFactory().GenerateStatistics();

            var mapper = new ConventionModelMapper();

            // filter entities
            var baseEntityType = typeof(AbstractEntity);
            mapper.IsEntity(
                (t, declared) => baseEntityType.IsAssignableFrom(t) && baseEntityType != t && !t.IsInterface);
            mapper.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType));

            // override base properties
            mapper.Class<AbstractEntity>(
                map =>
                    {
                        map.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
                    });

            mapper.BeforeMapProperty += OnBeforeMapProperty;

            // compile
            var mapping =
                mapper.CompileMappingFor(
                    typeof(AbstractEntity).Assembly.GetExportedTypes().Where(type => typeof(AbstractEntity).IsAssignableFrom(type)));

            // use mappings
            cfg.AddMapping(mapping);

            // build
            return cfg.BuildSessionFactory();
        }
开发者ID:SaleemCB,项目名称:AzureSamples,代码行数:42,代码来源:SessionFactoryProvider.cs

示例7: WhenVersionFromBaseEntityThenShouldntMapVersionAsProperty

		public void WhenVersionFromBaseEntityThenShouldntMapVersionAsProperty()
		{
			var mapper = new ConventionModelMapper();
			var baseEntityType = typeof(BaseEntity);
			mapper.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && baseEntityType != t && !t.IsInterface);
			mapper.IsRootEntity((t, declared) => baseEntityType == t.BaseType);
			mapper.Class<BaseEntity>(
				map =>
				{
					map.Id(x => x.Id, idmap => { });
					map.Version(x => x.Version, vm => { });
				});
			var hbmMapping = mapper.CompileMappingFor(new[] { typeof(Person) });

			var hbmClass = hbmMapping.RootClasses[0];
			var hbmVersion = hbmClass.Version;
			Assert.That(hbmVersion, Is.Not.Null);
			Assert.That(hbmVersion.name, Is.EqualTo("Version"));
			Assert.That(hbmClass.Properties, Is.Empty, "because one is the POID and the other is the version");
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:20,代码来源:VersionOnBaseClassIntegrationTest.cs

示例8: Configure

        public void Configure(Configuration configuration)
        {
            var mapper = new ConventionModelMapper();

            var baseEntityType = typeof (Entity);
            mapper.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && baseEntityType != t && !t.IsInterface);
            mapper.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType));

            mapper.BeforeMapManyToOne += (insp, prop, map) => map.Column(prop.LocalMember.GetPropertyOrFieldType().Name + "Id");
            mapper.BeforeMapBag += (insp, prop, map) => map.Key(km => km.Column(prop.GetContainerEntity(insp).Name + "Id"));
            mapper.BeforeMapBag += (insp, prop, map) => map.Cascade(Cascade.All);

            mapper.Class<Entity>(map =>
            {
                map.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
                map.Version(x => x.Version, m => m.Generated(VersionGeneration.Never));
            });

            var mapping = mapper.CompileMappingFor(baseEntityType.Assembly.GetExportedTypes());

            configuration.AddDeserializedMapping(mapping, "Cronos");
        }
开发者ID:mravinale,项目名称:simple-cqrs,代码行数:22,代码来源:EntitiesMapper.cs

示例9: Generate

        public static HbmMapping Generate()
        {
            //Conventions
              var mapper = new ConventionModelMapper();
              var baseEntity = typeof (EntityBase);

              mapper.BeforeMapProperty += (ispector, member, customizer) => customizer.Length(40);

              mapper.BeforeMapManyToOne +=
            (insp, prop, map) => map.Column(prop.LocalMember.GetPropertyOrFieldType().Name + "Id");

              mapper.BeforeMapManyToOne +=
            (insp, prop, map) => map.Cascade(Cascade.Persist);

              mapper.BeforeMapBag +=
            (insp, prop, map) => map.Key(km => km.Column(prop.GetContainerEntity(insp).Name + "Id"));

              mapper.BeforeMapSet +=
            (insp, prop, map) => map.Key(km => km.Column(prop.GetContainerEntity(insp).Name + "Id"));

              mapper.IsEntity((t, d) => baseEntity.IsAssignableFrom(t) && baseEntity != t);

              mapper.IsRootEntity((t, d) => t.BaseType == baseEntity);

              mapper.IsSet(IsSetFieldType);

              Customize(mapper);

              HbmMapping mappings = mapper.CompileMappingFor(new[]
                                                     {
                                                       typeof (Customization), typeof (Order),
                                                       typeof (Payment),
                                                       typeof (OrderItem), typeof (Product)
                                                     });
              return mappings;
        }
开发者ID:horsdal,项目名称:Restbucks-on-Nancy,代码行数:36,代码来源:Mapper.cs

示例10: ExcludeBaseEntity

 public static void ExcludeBaseEntity(ConventionModelMapper modelMapper, Type baseEntityType)
 {
     modelMapper.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && baseEntityType != t && !t.IsInterface);
     modelMapper.IsRootEntity((type, declared) => type.BaseType != null && type.BaseType.Equals(baseEntityType));
 }
开发者ID:mellibo,项目名称:MappingByCodeConvention,代码行数:5,代码来源:EntityConventions.cs


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