流畅的 NHibernate AutoMap
我有一个关于 AutoMap xml 生成的问题。 我有两个类:
public class User
{
virtual public Guid Id { get; private set; }
virtual public String Name { get; set; }
virtual public String Email { get; set; }
virtual public String Password { get; set; }
virtual public IList<OpenID> OpenIDs { get; set; }
}
public class OpenID
{
virtual public Guid Id { get; private set; }
virtual public String Provider { get; set; }
virtual public String Ticket { get; set; }
virtual public User User { get; set; }
}
生成的 xml 文件序列是: 对于用户类:
<bag name="OpenIDs">
<key>
<column name="User_Id" />
</key>
<one-to-many class="BL_DAL.Entities.OpenID, BL_DAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bag>
For OpenID class:
<many-to-one class="BL_DAL.Entities.User, BL_DAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="User">
<column name="User_id" />
</many-to-one>
我没有看到用户映射的 inverse=true 属性。这是正常行为,还是我在某个地方犯了错误?
I have a qouestion regarding the AutoMap xml generation.
I have two classes:
public class User
{
virtual public Guid Id { get; private set; }
virtual public String Name { get; set; }
virtual public String Email { get; set; }
virtual public String Password { get; set; }
virtual public IList<OpenID> OpenIDs { get; set; }
}
public class OpenID
{
virtual public Guid Id { get; private set; }
virtual public String Provider { get; set; }
virtual public String Ticket { get; set; }
virtual public User User { get; set; }
}
The generated sequences of xml files are:
For User class:
<bag name="OpenIDs">
<key>
<column name="User_Id" />
</key>
<one-to-many class="BL_DAL.Entities.OpenID, BL_DAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bag>
For OpenID class:
<many-to-one class="BL_DAL.Entities.User, BL_DAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="User">
<column name="User_id" />
</many-to-one>
I don't see the inverse=true attribute for the User mapping. Is it a normal behavior, or I made a mistake somewhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认约定是不添加逆属性。您必须覆盖约定才能改变这一点。
The default convention is not to add the inverse attribute. You will have to overwrite the convention to change that.