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


C# ObjectRelationalMapper.List方法代码示例

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


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

示例1: NotRecognizeExplicitRegisteredAsListProperty

 public void NotRecognizeExplicitRegisteredAsListProperty()
 {
     var mapper = new ObjectRelationalMapper();
     mapper.List<A>(x => x.List);
     var mi = typeof(A).GetProperty("List");
     mapper.IsBag(mi).Should().Be.False();
 }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:7,代码来源:BagProperties.cs

示例2: RecognizeExplicitRegisteredAsListProperty

 public void RecognizeExplicitRegisteredAsListProperty()
 {
     var mapper = new ObjectRelationalMapper();
     mapper.List<A>(x => x.Bag);
     var mi = typeof(A).GetProperty("Bag");
     mapper.IsList(mi).Should().Be.True();
 }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:7,代码来源:ListProperties.cs

示例3: UseBagForListsWithCoolNaming

        public void UseBagForListsWithCoolNaming()
        {
            // this is the same example as the previous but this time using the CoolPatternsAppliersHolder and you can see
            // which is the difference

            var orm = new ObjectRelationalMapper();
            orm.Patterns.Lists.Remove(orm.Patterns.Lists.Single(p => p.GetType() == typeof(ListCollectionPattern)));
            orm.List<Contact>(contact => contact.Phones);

            var mapper = new Mapper(orm, new CoolPatternsAppliersHolder(orm));
            orm.TablePerClass<Contact>();

            // Show the mapping to the console
            var mapping = mapper.CompileMappingFor(new[] { typeof(Contact) });
            Console.Write(mapping.AsString());
        }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:16,代码来源:Demo.cs

示例4: UseBagForLists

        public void UseBagForLists()
        {
            // NH does not support <list> for bidirectional-one-to-many (aka parent child) and ConfORM know this fact so, in general, you don't have to do anything.
            // The IList<T> should be used only where the order is important in your domain.
            // Where the order is not important you can expose ICollection<T> (in a property or in a field).
            // If you want use IList<T> everywhere but you want map a IList<T> using a <bag> you can remove a pettern,
            // then you can always use the explicit declaration for those collection where you need a <list> mapping.

            var orm = new ObjectRelationalMapper();

            // With the follow line I'm removing the pattern to discover where map a <list>; doing so all IList<T> will be mapped using <bag>
            orm.Patterns.Lists.Remove(orm.Patterns.Lists.Single(p => p.GetType() == typeof(ListCollectionPattern)));

            // With the follow line I'm explicitly dwclaring that I want map the Contact.Phones property as <list>
            orm.List<Contact>(contact=> contact.Phones);

            var mapper = new Mapper(orm); // <== for this example the CoolPatternsAppliersHolder is not useful
            orm.TablePerClass<Contact>();

            // Show the mapping to the console
            var mapping = mapper.CompileMappingFor(new[] {typeof (Contact)});
            Console.Write(mapping.AsString());
        }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:23,代码来源:Demo.cs


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