我在 sql 类中有一个表,其中第一列是 ID,另一列是 fImage。fImage 列的数据类型是 Image。我正在使用 nhibernate 加载所有图像并希望将其绑定到图片框控件中。但是我们在使用 nhibernate 读取数据时遇到异常,因为nhibernate 无法反序列化可序列化的属性。
我浏览了一些关于 stackoverflow 和 google 的链接,但似乎没有什么对我有用。
在这里,我给出了示例 hbm 文件和类文件。
namespace BlackOpsP2.Core.Domain.ARModule
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
/// <summary>
/// Documentation for the tARReportLogo.
/// </summary>
public partial class tARReportLogo : DomainObject<System.Guid>
{
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="tARReportLogo"/> class.
/// </summary>
public tARReportLogo()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="tARReportLogo"/> class.
/// </summary>
/// <param name="fReportLogoID">The Payment Type ID.</param>
public tARReportLogo(System.Guid fReportLogoID)
{
this.ID = fReportLogoID;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets ReportLogoID.
/// </summary>
public virtual System.Guid fReportLogoID { get; set; }
/// <summary>
/// Gets or sets Image ID.
/// </summary>
public virtual System.Guid fImageID { get; set; }
/// <summary>
/// Gets or sets Image Name.
/// </summary>
public virtual string fImageName { get; set; }
/// <summary>
/// Gets or sets Image Value.
/// </summary>
public virtual Image fImageValue { get; set; }
#endregion
#region Methods
/// <summary>
/// Joins a first name and a last name together into a single string.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode()
{
return ID.GetHashCode();
}
#endregion
}
}
这是hbm文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping assembly="BlackOpsP2.Core" namespace="BlackOpsP2.Core.Domain.ARModule" xmlns="urn:nhibernate-mapping-2.2">
<class name="tARReportLogo" table="tARReportLogo" lazy="true" >
<id name="fReportLogoID">
<generator class="guid" />
</id>
<property name="fImageID">
</property>
<property name="fImageName" >
</property>
<property name="fImageValue" type="Serializable" length="2147483647">
</property>
</class>
</hibernate-mapping>
我正在使用休眠 3.3 版。
谢谢,