1
我的模型对象Reading
有一个Location
,但它不是数据库中的直接关系。在DB,这个“有”的关系或“参考”跨越3个表,如本喀嚓:References/has-a mapping through 3 tables
我Reading
映射到ComponentReading表,我想我的Location
映射到地点表。我ClassMap<Reading>
类看起来是这样的,现在:
public class ReadingMap : ClassMap<Reading>
{
public ReadingMap()
{
Table("ComponentReading");
Id(x => x.ID).Column("ComponentReadingId");
//References(x => x.Location).Formula(
Join("VehicleReading", vr =>
{
Join("TrainReading", tr =>
{
tr.References(x => x.Location, "LocationId");
});
});
Map(x => x.TemperatureValue).Column("Temperature");
}
}
这里是我的简单Location
映射:
public class LocationMap : ClassMap<Location>
{
public LocationMap()
{
Id(x => x.ID).Column("LocationId");
Map(x => x.Name);
}
}
的评论References(
方法排序说明了什么,我想实现与Reading
和Location
之间的关系但显然我无法像FNH那样简单地将它表达出来。
我不认为Join(
代码甚至几乎是正确的,但它也试图沟通我之后的关系。
我希望有人能看到我想在这里做什么。你可以帮我吗?