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


C# Mapper.AddManyToOnePattern方法代码示例

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


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

示例1: AddSimpleCustomDelegatedManyToOneApplierWithMember

        public void AddSimpleCustomDelegatedManyToOneApplierWithMember()
        {
            var orm = new Mock<IDomainInspector>();
            var mapper = new Mapper(orm.Object);
            var previousManyToOneApplierCount = mapper.PatternsAppliers.ManyToOne.Count;

            mapper.AddManyToOnePattern(mi => true, cm => { });

            mapper.PatternsAppliers.ManyToOne.Count.Should().Be(previousManyToOneApplierCount + 1);
        }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:10,代码来源:ManyToOnePatternsAddition.cs

示例2: WhenRegisterApplierOnManyToOneThenInvokeApplier

        public void WhenRegisterApplierOnManyToOneThenInvokeApplier()
        {
            Mock<IDomainInspector> orm = GetMockedDomainInspector();
            var mapper = new Mapper(orm.Object);
            mapper.AddManyToOnePattern(mi=> mi.GetPropertyOrFieldType() == typeof(Skill), mtom=> mtom.Column("SkillId"));

            HbmMapping mapping = mapper.CompileMappingFor(new[] { typeof(Person) });
            var rc = mapping.RootClasses.Single();
            var map = rc.Properties.OfType<HbmMap>().Single();
            var hbmCompositeMapKey = (HbmCompositeMapKey)map.Item;
            var hbmKeyManyToOne = (HbmKeyManyToOne)hbmCompositeMapKey.Properties.Single(p => p.Name == "Skill");

            hbmKeyManyToOne.Columns.Single().name.Should().Be("SkillId");
        }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:14,代码来源:MapKeyComponentRelationAppliersCallingTest.cs

示例3: CallPatternAppliersOnNestedCompositeElements

        public void CallPatternAppliersOnNestedCompositeElements()
        {
            Mock<IDomainInspector> orm = GetMockedDomainInspector();
            var mapper = new Mapper(orm.Object);
            bool reSimplePropertyCalled = false;
            bool reManyToOneCalled = false;

            mapper.AddPropertyPattern(mi => mi.DeclaringType == typeof(MyNestedComponent), pm => reSimplePropertyCalled = true);
            mapper.AddManyToOnePattern(mi => mi.DeclaringType == typeof(MyNestedComponent), pm => reManyToOneCalled = true);

            mapper.CompileMappingFor(new[] { typeof(MyClass) });
            reSimplePropertyCalled.Should().Be.True();
            reManyToOneCalled.Should().Be.True();
        }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:14,代码来源:AppliersCallingOnCompositeElementTest.cs

示例4: CustomizeColumns

        private void CustomizeColumns(Mapper mapper)
        {
            // in EditionQuotation all references to a class inherited from Cost are not nullables (this is only an example because you can do it one by one)
            mapper.AddManyToOnePattern(
                mi => mi.DeclaringType == typeof (EditionQuotation) && typeof (Cost).IsAssignableFrom(mi.GetPropertyOrFieldType()),
                map => map.NotNullable(true));

            // in Quotation all string properties are not nullables (this is only an example because you can do it one by one)
            mapper.AddPropertyPattern(
                mi => mi.DeclaringType == typeof (Quotation) && mi.GetPropertyOrFieldType() == typeof (string),
                map => map.NotNullable(true));

            // Quotation columns size customization (if you use a Validator framework you can implements a pattern-applier to customize columns size and "nullable" stuff)
            // Note: It is needed only for properties without a convention (the property Description has its convetion)
            mapper.Customize<Quotation>(map =>
                                            {
                                                map.Property(q => q.Code, pm => pm.Length(10));
                                                map.Property(q => q.Reference, pm => pm.Length(50));
                                                map.Property(q => q.PaymentMethod, pm => pm.Length(50));
                                                map.Property(q => q.TransportMethod, pm => pm.Length(50));
                                            });

            // Column customization for class ProductQuotation
            // Note: It is needed only for properties outside conventions
            mapper.Customize<ProductQuotation>(map => map.Property(pq => pq.Group, pm =>
                                                                                   	{
                                                                                   		pm.Length(50);
                                                                                   		pm.Column("GroupName");
                                                                                   	}));
        }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:30,代码来源:Demo.cs


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