我有以下数据库设置:
我需要一个nhibernate文件,将其映射到:
PowerPrognosisUsageSubmission
class PowerPrognosisWindSubmission
class PowerPrognosisSubmissionBase
抽象基类虽然,我无处可去。这是我的尝试:
我尝试实施PowerPrognosisUsageSubmission
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping namespace="DC.Client.Models.Model" assembly="DC.Client.Models" xmlns="urn:nhibernate-mapping-2.2">
<class name="PowerPrognosisUsageSubmission" table="PowerPrognosisSubmissionBase" schema="`dbo`" mutable="true" lazy="false">
<id name="PowerPrognosisSubmissionId" access="property" column="`PowerPrognosisSubmissionBaseID`">
<generator class="native" />
</id>
<property name="Date" column="`Date`" />
<property name="Hour" column="`Hour`" />
<property name="Direction" column="`Direction`" />
<property name="Submission" column="`Submission`" />
<property name="Basis" column="`Basis`" />
<many-to-one name="PowerPrognosisUsageArea" class="PowerPrognosisUsageArea" column="`PowerPrognosisAreaBaseID`" not-null="false" lazy="false" />
<joined-subclass name="PowerPrognosisUsageSubmission" table="PowerPrognosisUsageSubmission">
<key column="`Usage`" />
</joined-subclass>
</class>
</hibernate-mapping>
任何帮助?
答案 0 :(得分:1)
我自己解决了它
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping namespace="DC.Client.Models.Model" assembly="DC.Client.Models" xmlns="urn:nhibernate-mapping-2.2">
<class name="PowerPrognosisSubmissionBase" table="PowerPrognosisSubmissionBase" schema="`dbo`" mutable="true" lazy="false">
<id name="PowerPrognosisSubmissionId" access="property" column="`PowerPrognosisSubmissionBaseID`">
<generator class="native" />
</id>
<property name="Date" column="`Date`" />
<property name="Hour" column="`Hour`" />
<property name="Direction" column="`Direction`" />
<property name="Submission" column="`Submission`" />
<property name="Basis" column="`Basis`" />
<many-to-one name="PowerPrognosisAreaUsage" class="PowerPrognosisAreaUsage" column="`PowerPrognosisAreaBaseID`" not-null="false" lazy="false" />
<joined-subclass name="PowerPrognosisSubmissionUsage" table="PowerPrognosisSubmissionUsage">
<key column="`PowerPrognosisSubmissionBaseID`" />
<property name="Usage" column="`Usage`" />
</joined-subclass>
<joined-subclass name="PowerPrognosisSubmissionWind" table="PowerPrognosisSubmissionWind">
<key column="`PowerPrognosisSubmissionBaseID`" />
<property name="PriceAreaEffect" column="`PriceAreaEffect`" />
<property name="ResponsibleEffect" column="`ResponsibleEffect`" />
<property name="W2UShare" column="`W2UShare`" />
<property name="PointCarbonShare" column="`PointCarbonShare`" />
</joined-subclass>
</class>
</hibernate-mapping>
答案 1 :(得分:0)
我建议你看看FluentNhibernate,在我看来,它提供了一种更好的方法来将表映射到你的实体类。
此外,您可能想要使用此工具,它可以为您生成hbm.xml或fluentnhibernate映射文件。
答案 2 :(得分:-2)
也许你应该阅读NHibernate manual。 Chapter 8包含有关继承的所有详细信息。