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


C# SimpleModelInspector.IsRootEntity方法代码示例

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


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

示例1: WhenCustomizedThenUseCustomizedPredicate

		public void WhenCustomizedThenUseCustomizedPredicate()
		{
			var autoinspector = new SimpleModelInspector();
			autoinspector.IsRootEntity((t, declared) => typeof(BaseEntity).Equals(t.BaseType));

			var inspector = (IModelInspector)autoinspector;

			Assert.That(inspector.IsRootEntity(typeof(Person)), Is.False);
			Assert.That(inspector.IsRootEntity(typeof(Product)), Is.True);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:10,代码来源:RootEntityTests.cs

示例2: WhenMapPropertiesInTheBaseJumpedClassUsingMemberNameThenMapInInherited

		public void WhenMapPropertiesInTheBaseJumpedClassUsingMemberNameThenMapInInherited()
		{
			// ignoring MyClass and using Inherited, as root-class, I will try to map all properties using the base class.
			// NH have to recognize the case and map those properties in the inherited.
			var inspector = new SimpleModelInspector();
			inspector.IsEntity((type, declared) => type == typeof(Inherited));
			inspector.IsRootEntity((type, declared) => type == typeof(Inherited));
			var mapper = new ModelMapper(inspector);
			mapper.Class<MyClass>(mc =>
								  {
									mc.Id(x => x.Id);
									mc.Property("Simple", map => map.Access(Accessor.Field));
									mc.Property("ComplexType", map => map.Access(Accessor.Field));
									mc.Bag<string>("Bag", y => y.Access(Accessor.Field));
									mc.IdBag<MyCompo>("IdBag", y => y.Access(Accessor.Field));
									mc.List<string>("List", y => y.Access(Accessor.Field));
									mc.Set<string>("Set", y => y.Access(Accessor.Field));
									mc.Map<int, string>("Map", y => y.Access(Accessor.Field));
									mc.OneToOne<Related>("OneToOne", y => y.Access(Accessor.Field));
									mc.ManyToOne<Related>("ManyToOne", y => y.Access(Accessor.Field));
									mc.Any<object>("Any", typeof (int), y => y.Access(Accessor.Field));
									mc.Component("DynamicCompo", new {A = 2}, y => y.Access(Accessor.Field));
									mc.Component<MyCompo>("Compo", y =>
																   {
																	y.Access(Accessor.Field);
																	y.Property(c => c.Something);
																   });
								  });
			mapper.Class<Inherited>(mc => { });

			HbmMapping mappings = mapper.CompileMappingForAllExplicitlyAddedEntities();
			HbmClass hbmClass = mappings.RootClasses[0];
			Assert.That(mappings.JoinedSubclasses, Is.Empty);
			Assert.That(hbmClass.Properties.Select(p => p.Name), Is.EquivalentTo(new [] {"Simple", "ComplexType", "Bag", "IdBag", "List", "Set", "Map", "Compo", "OneToOne", "ManyToOne", "Any", "DynamicCompo"}));
			Assert.That(hbmClass.Properties.Select(p => p.Access).All(a => a.StartsWith("field.")), Is.True);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:36,代码来源:AllPropertiesRegistrationTests.cs

示例3: WhenMapPropertiesInTheBaseJumpedClassThenMapInInherited

		public void WhenMapPropertiesInTheBaseJumpedClassThenMapInInherited()
		{
			// ignoring MyClass and using Inherited, as root-class, I will try to map all properties using the base class.
			// NH have to recognize the case and map those properties in the inherited.
			var inspector = new SimpleModelInspector();
			inspector.IsEntity((type, declared) => type == typeof(Inherited));
			inspector.IsRootEntity((type, declared) => type == typeof(Inherited));
			var mapper = new ModelMapper(inspector);
			mapper.Class<MyClass>(mc =>
			                      {
			                      	mc.Id(x => x.Id);
			                      	mc.Property(x => x.Simple, map => map.Access(Accessor.Field));
			                      	mc.Property(x => x.ComplexType, map => map.Access(Accessor.Field));
			                      	mc.Bag(x => x.Bag, y => y.Access(Accessor.Field));
			                      	mc.IdBag(x => x.IdBag, y => y.Access(Accessor.Field));
			                      	mc.List(x => x.List, y => y.Access(Accessor.Field));
			                      	mc.Set(x => x.Set, y => y.Access(Accessor.Field));
			                      	mc.Map(x => x.Map, y => y.Access(Accessor.Field));
															mc.OneToOne(x => x.OneToOne, y => y.Access(Accessor.Field));
															mc.ManyToOne(x => x.ManyToOne, y => y.Access(Accessor.Field));
															mc.Any(x => x.Any, typeof(int), y => y.Access(Accessor.Field));
															mc.Component(x => x.DynamicCompo, new { A = 2 }, y => y.Access(Accessor.Field));
															mc.Component(x => x.Compo, y =>
			                      	                           {
			                      	                           	y.Access(Accessor.Field);
			                      	                           	y.Property(c => c.Something);
			                      	                           });
			                      });
			mapper.Class<Inherited>(mc =>{});

			var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities();
			var hbmClass = mappings.RootClasses[0];
			mappings.JoinedSubclasses.Should().Be.Empty();
			hbmClass.Properties.Select(p => p.Name).Should().Have.SameValuesAs("Simple", "ComplexType", "Bag", "IdBag", "List", "Set", "Map", "Compo", "OneToOne", "ManyToOne", "Any", "DynamicCompo");
			hbmClass.Properties.Select(p => p.Access).All(x => x.Satisfy(access => access.Contains("field.")));
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:36,代码来源:AllPropertiesRegistrationTests.cs


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