使用 Fluent nhibernate 在关系表中配置一对 0 或 1 关系
这是我的课程:
public class User {
public virtual int Id { get; private set;}
public virtual IList<Bike> { get; set;}
}
public class Bike {
public virtual int Id { get; private set;}
public virtual string color { get; set;}
}
public class Accident{
public virtual int Id { get; private set;}
public virtual User User{ get; set;}
public virtual Bike Bike{ get; set;}
}
和我的表格
- 用户:Id
- 自行车:Id、颜色、用户(fk)
- 事故:Id
- AccdentOccurance:AccidentId、UserId、BikeId
事故可能与自行车相关(隐式与自行车的用户相关),或者给用户,但不是自行车。 我的问题是如何配置 Accident ClassMap 以与 AccidentOccurance 表一起使用?
希望你能帮忙。
Here are my classes:
public class User {
public virtual int Id { get; private set;}
public virtual IList<Bike> { get; set;}
}
public class Bike {
public virtual int Id { get; private set;}
public virtual string color { get; set;}
}
public class Accident{
public virtual int Id { get; private set;}
public virtual User User{ get; set;}
public virtual Bike Bike{ get; set;}
}
And my tables
- User: Id
- Bike: Id, color, user(fk)
- Accident: Id
- AccdentOccurance: AccidentId, UserId, BikeId
An accident can be related to a bike(implicit to the user of the bike), or to a user, but not a bike.
My question is how do I configure the Accident ClassMap to work with the AccidentOccurance table?
Hope you can help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)