本文整理汇总了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();
}
示例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();
}
示例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());
}
示例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());
}