[英]nhibernate mapping from fluent to mapping by code
One Country
has many States
. 一个
Country
有许多States
。 One State belongs to one Country. 一个国家属于一个国家。 Mapping Country property in StateMap using fluent mapping was
使用流畅映射在StateMap中映射Country属性
public StateMap()
{
...
References(m => m.Country).Not.Nullable();
}
what is nhibernate mapping by code alternative 什么是代码替代的nhibernate映射
should I simply map Country as property 我应该简单地将Country映射为属性
Property(m => m.Country});
The alternative to References is Mapping-by-Code - ManyToOne References的替代方案是Mapping-by-Code - ManyToOne
ManyToOne(x => x.Country, m =>
{
m.Column("column_country");
// or...
m.Column(c =>
{
c.Name("column_country");
// other standard column options
});
...
The HasMany is Mapping-by-Code - Set and Bag HasMany是按代码映射 - 设置和包
Set(x => x.States, c =>
{
c.Lazy(CollectionLazy.Lazy); // or CollectionLazy.NoLazy, CollectionLazy.Extra
c.Table("tableName");
c.Schema("schemaName");
c.BatchSize(100);
...
The links provided above are the best place where to start observing the mapping by code 上面提供的链接是开始通过代码观察映射的最佳位置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.