fluid-nhibernate 映射 HasOne?参考?
不知道我应该如何映射它。我有两个表
Week 与列
Id、SeasionId、WeekStarts、MatchOfTheWeek
Matches 与列
Id、Location、MatchDate、Rounds
我的 Weeks 类有一个类型为 Match
public virtual Match MatchOfTheWeek
{
get;
set;
}
Now I 的对象在我的比赛
public MatchMapping()
{
Id(x => x.Id);
Map(x => x.Location);
Map(x => x.Rounds);
Map(x => x.MatchDate).Nullable();
HasManyToMany(x => x.Boxers)
.Table("Boxer_Match")
.ParentKeyColumn("matchid")
.ChildKeyColumn("boxerid")
.AsSet()
.Cascade.SaveUpdate();
HasOne(x => x.Result)
.Cascade.Delete();
}
和我的周映射
public WeekMapping()
{
Id(x => x.Id);
References(x => x.Season);
HasMany(x => x.Predictions).Cascade.SaveUpdate().Inverse();
HasOne(x => x.MatchOfTheWeek).ForeignKey("MatchOfTheWeek");
//References(x => x.MatchOfTheWeek).Nullable();
HasManyToMany(x => x.Matches)
.Table("WeekMatch")
.ParentKeyColumn("WeekID")
.ChildKeyColumn("MatchId")
.AsSet()
.Cascade.All();
Map(x => x.WeekStarts);
}
上有映射基本上,当周映射显示在那里时,它会出错。如果我换出 HasOne 以将其替换为作为参考的注释行。那么它不会出错,但会返回 null
我在这里做错了什么?
Not sure how I should map this. I have two tables
Week with the columns
Id, SeasionId, WeekStarts, MatchOfTheWeek
Matches with the columns
Id, Location, MatchDate, Rounds
my Weeks classhas a object of type Match
public virtual Match MatchOfTheWeek
{
get;
set;
}
Now I have mapping on my Match
public MatchMapping()
{
Id(x => x.Id);
Map(x => x.Location);
Map(x => x.Rounds);
Map(x => x.MatchDate).Nullable();
HasManyToMany(x => x.Boxers)
.Table("Boxer_Match")
.ParentKeyColumn("matchid")
.ChildKeyColumn("boxerid")
.AsSet()
.Cascade.SaveUpdate();
HasOne(x => x.Result)
.Cascade.Delete();
}
and my Week mappings
public WeekMapping()
{
Id(x => x.Id);
References(x => x.Season);
HasMany(x => x.Predictions).Cascade.SaveUpdate().Inverse();
HasOne(x => x.MatchOfTheWeek).ForeignKey("MatchOfTheWeek");
//References(x => x.MatchOfTheWeek).Nullable();
HasManyToMany(x => x.Matches)
.Table("WeekMatch")
.ParentKeyColumn("WeekID")
.ChildKeyColumn("MatchId")
.AsSet()
.Cascade.All();
Map(x => x.WeekStarts);
}
Bascially As the Weekmapping is shown there it errors. If i swap out the HasOne to replace it with the commented line which is a Reference. then it doesn't error but returns a null
What have i done wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你可能想使用:
如果我错了,请纠正我,但我认为它会尝试使用默认约定的
MatchOfTheWeek_id
列。I think you'd probably want to use:
Correct me if I'm wrong, but I think it would be trying to use the column
MatchOfTheWeek_id
using the default conventions.