SQLクラスにテーブルがあり、1つはIDで、もう1つは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>
nhibernateバージョン3.3を使用しています。
ありがとう、