我剛開始學習Nhibernate。我有映射(確切關係)的問題。 我有兩個表:映射文件的問題(關係)
表1(DIC_TOWN)
TOWN_ID
1
2
3
表2(DIC_TOWN_STRINGS)
TOWN_ID LANG_ID TOWN_NAME
1 1 CityName
1 2 CityName
2 1 CityName
2 2 CityName
我的類:
public class TownS
{
public virtual int TownId { get; set; }
public virtual Languages LangId { get; set; }
public virtual string TownName { get; set; }
}
編輯:
我的映射文件:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="EArchive.Data" namespace="EArchive.Data.Class">
<class name="TownS" table="DIC_TOWN_STRINGS" lazy="false">
<composite-id>
<key-property name="TownId" column="TOWN_ID" />
<key-property name="LangId" column="LANG_ID" />
</composite-id>
<property name="TownName" column="TOWN_NAME" />
<many-to-one name="LangId" column="LANG_ID"/>
</class>
</hibernate-mapping>
幫我寫映射文件。如果可能的話,解釋。謝謝。
什麼是「TownS」和「Languages」類? –