本文整理汇总了C#中Mapper.CompileMappingForEach方法的典型用法代码示例。如果您正苦于以下问题:C# Mapper.CompileMappingForEach方法的具体用法?C# Mapper.CompileMappingForEach怎么用?C# Mapper.CompileMappingForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapper
的用法示例。
在下文中一共展示了Mapper.CompileMappingForEach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAMappingForEachClass
public void CreateAMappingForEachClass()
{
var orm = new Mock<IDomainInspector>();
orm.Setup(m => m.IsEntity(It.Is<Type>(t => t == typeof(Person) || t == typeof(Address) || t == typeof(SpecialAddress)))).Returns(true);
orm.Setup(m => m.IsRootEntity(It.Is<Type>(t => t == typeof(Person) || t == typeof(Address)))).Returns(true);
orm.Setup(m => m.IsTablePerClass(It.IsAny<Type>())).Returns(true);
orm.Setup(m => m.IsPersistentId(It.Is<MemberInfo>(mi => mi.Name == "Id"))).Returns(true);
orm.Setup(m => m.IsPersistentProperty(It.Is<MemberInfo>(mi => mi.Name != "Id"))).Returns(true);
var mapper = new Mapper(orm.Object);
mapper.CompileMappingForEach(new[] {typeof (Person), typeof (Address)}).Should().Have.Count.EqualTo(2);
mapper.CompileMappingForEach(new[] { typeof(Person), typeof(SpecialAddress), typeof(Address) }).Should().Have.Count.EqualTo(3);
}
示例2: EachMapDocShouldSetDefaultNamespace
public void EachMapDocShouldSetDefaultNamespace()
{
var entities = new[] { typeof(MyEntity), typeof(AEntity), typeof(Inherited) };
var di = new Mock<IDomainInspector>();
di.Setup(m => m.IsEntity(It.IsAny<Type>())).Returns(true);
di.Setup(m => m.IsRootEntity(It.Is<Type>(t => t != typeof(Inherited)))).Returns(true);
di.Setup(m => m.IsTablePerClass(It.IsAny<Type>())).Returns(true);
di.Setup(m => m.IsPersistentId(It.Is<MemberInfo>(mi => mi.Name == "Id"))).Returns(true);
di.Setup(m => m.IsPersistentProperty(It.Is<MemberInfo>(mi => mi.Name != "Id"))).Returns(true);
var mapper = new Mapper(di.Object);
var mappings = mapper.CompileMappingForEach(entities);
mappings.All(md => md.Satisfy(mapDoc => typeof(MyEntity).Namespace.Equals([email protected])));
}