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


C# Mapper.AddCollectionPattern方法代码示例

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


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

示例1: AddCustomDelegatedApplierWithMember

        public void AddCustomDelegatedApplierWithMember()
        {
            var orm = new Mock<IDomainInspector>();
            var mapper = new Mapper(orm.Object);
            var previousCollectionApplierCount = mapper.PatternsAppliers.Collection.Count;

            mapper.AddCollectionPattern(mi => true, (mi, cm) => cm.BatchSize(25));

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

示例2: AppliesGeneralConventions

        private void AppliesGeneralConventions(Mapper mapper)
        {
            const string softDeleteWhereClause = "DeletedOn is NULL";

            // because VersionModelBase is not an entity I can use the it to customize the mapping of all inherited classes
            mapper.Class<VersionModelBase>(map => map.Where(softDeleteWhereClause));

            // When the collection elements inherits from VersionModelBase then should apply the where-clause for "soft delete"
            mapper.AddCollectionPattern(mi => mi.GetPropertyOrFieldType().IsGenericCollection() &&
                                              typeof (VersionModelBase).IsAssignableFrom(
                                              	mi.GetPropertyOrFieldType().DetermineCollectionElementType())
                                        , map => map.Where(softDeleteWhereClause));

            // The default length for string is 100
            // Note : because this convetion has no specific restriction other than typeof(string) should be added at first (the order, in this case, is important)
            mapper.AddPropertyPattern(mi => mi.GetPropertyOrFieldType() == typeof(string), map => map.Length(100));

            // When the property name is Description and is of type string then apply length 500
            mapper.AddPropertyPattern(mi => mi.Name == "Description" && mi.GetPropertyOrFieldType() == typeof (string),
                                      map => map.Length(500));

            // When the property is of type decimal and it refers to a price then applies Currency
            mapper.AddPropertyPattern(mi => mi.Name.EndsWith("Cost") && mi.GetPropertyOrFieldType() == typeof (decimal),
                                      map => map.Type(NHibernateUtil.Currency));
        }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:25,代码来源:Demo.cs

示例3: Act

 private HbmMapping Act(Mock<IDomainInspector> orm)
 {
     var mapper = new Mapper(orm.Object);
     mapper.AddCollectionPattern(mi => true, cm => cm.BatchSize(25));
     return mapper.CompileMappingFor(new[] { typeof(MyClass) });
 }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:6,代码来源:CustomCollectionPatternApplierTest.cs


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