本文整理汇总了C#中NHibernate.Mapping.ByCode.SimpleModelInspector.IsEntity方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleModelInspector.IsEntity方法的具体用法?C# SimpleModelInspector.IsEntity怎么用?C# SimpleModelInspector.IsEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Mapping.ByCode.SimpleModelInspector
的用法示例。
在下文中一共展示了SimpleModelInspector.IsEntity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenRelationWithTwoEntityThenIsManyToOne
public void WhenRelationWithTwoEntityThenIsManyToOne()
{
var autoinspector = new SimpleModelInspector();
autoinspector.IsEntity((t, declared) => typeof(AEntity).Equals(t) || typeof(BEntity).Equals(t));
var inspector = (IModelInspector)autoinspector;
Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("B")), Is.True);
}
示例2: WhenSimplePropertyThenIsNotManyToOne
public void WhenSimplePropertyThenIsNotManyToOne()
{
var autoinspector = new SimpleModelInspector();
autoinspector.IsEntity((t, declared) => typeof(AEntity).Equals(t) || typeof(BEntity).Equals(t));
var inspector = (IModelInspector)autoinspector;
Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("Name")), Is.False);
}
示例3: WhenRelatedMatchComponentThenIsNotManyToOne
public void WhenRelatedMatchComponentThenIsNotManyToOne()
{
var autoinspector = new SimpleModelInspector();
autoinspector.IsEntity((t, declared) => typeof(AEntity).Equals(t));
autoinspector.IsComponent((t, declared) => typeof(BEntity).Equals(t));
var inspector = (IModelInspector)autoinspector;
Assert.That(inspector.IsManyToOne(typeof(AEntity).GetProperty("B")), Is.False);
}
示例4: 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);
}
示例5: 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.")));
}