【发布时间】:2014-10-07 10:50:12
【问题描述】:
我在映射这个时遇到了问题……这有可能吗?
这是一个例子:
public class Location{
public int ID {get;set;}
public float Latitude {get;set;}
public float Longitude {get;set;}
public IEnumerable<Weather> Weather {get;set;}
}
public class Weather{
public int ID {get;set;}
public float Latitude {get;set;}
public float Longitude {get;set;}
public DateTime TimeMeasured {get;set;}
public float Temperature {get;set;}
...
}
所以我想在Location 和Weather 实体之间建立关系。它们可以通过Latitude 和Longitude 属性加入,但我不知道如何映射它。
这是我尝试过的:
<class table="locations" name="Model.Location, Model">
...
<set name="Weather" lazy="extra">
<key>
<column name="Latitude" />
<column name="Longitude" />
</key>
<one-to-many class="Model.Weather, Model" />
</set>
...
</class>
它抛出一个:
Foreign key (FK911522E81A761796:weather [Latitude, Longitude])) must have same number of columns as the referenced primary key (locations [ID]):
【问题讨论】:
标签: c# .net nhibernate orm nhibernate-mapping