因此,我在 NHibernate 3.0 中与我的 xml 文件的映射出现错误。我有一个 MediaContent 类,我正在尝试绘制它并且遇到了问题。我知道这与我的 xml 映射有关,因为该映射未显示在我的配置中。
这是 MediaContent 类(枚举是 ContentAccessibility 和 MediaTypes):
public class MediaContent:IMediaContent,ICreatedAndModified, IActive, IArchived
{
#region Properties/Members
public int MediaContentID { get; set; }
public string Name { get; set; }
public string FileName { get; set; }
public ContentAccessibility Accessibility { get; set; }
public MediaTypes MediaType { get; set; }
public object Media { get; set; }
public Dictionary<string, object> MediaProperties { get; set; }
public string Author { get; set; }
public string InternalIdentifier { get; set; }
public string CreatedBy { get; private set; }
public DateTime? CreatedOn { get; private set; }
public string LastModifiedBy { get; private set; }
public DateTime? LastModifiedOn { get; private set; }
public string ComplianceCode { get; private set; }
public bool IsActive { get; private set; }
public bool Archived { get; private set; }
#endregion
#region Methods
public void Create(DateTime createdOn, string createdBy)
{
CreatedOn = createdOn;
CreatedBy = createdBy;
}
public void Modified(DateTime modifiedOn, string modifiedBy)
{
LastModifiedBy = modifiedBy;
LastModifiedOn = modifiedOn;
}
#endregion
}
这是 MediaContent.hbm.xml 文件:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Domain"
namespace="Domain.Models">
<class name="MediaContent" lazy="false" table="MediaContent">
<!-- Identity Mapping-->
<id name="MediaContentID">
<column name="MediaContentID" />
<generator class="native" />
</id>
<!-- Simple Property Mappings-->
<property name="Name" />
<property name="FileName" />
<property name="Accessibility" />
<property name="MediaType" />
<property name="Media" />
<property name="Author" />
<property name="InternalIdentifier" />
<property name="ComplianceCode" />
<property name="CreatedBy" />
<property name="CreatedOn" />
<property name="LastModifiedBy" />
<property name="LastModifiedOn" />
<property name="IsActive" />
<property name="Archived" />
</class>
</hibernate-mapping>
可能是我忽略了 NHibernate 的工作方式,但据我所知,其他情况应该没问题。