在用NHibernate ,发现他提供的属性访问策略有三种
分别是:
 <property name="XX" access="field|property|classname"/>
资料上大都提了一下,并说默认是按 property访问的,
现在做的项目有个需求需要 access="classname" 按类名访问,我定义了两个实体类:
namespace Entity
{
/// <summary>
/// TestClassName 的摘要说明。
/// </summary>
public class TestClassName
{
private int id;
private ArithmeticClass arithmetic;//算法 public int Id
{
get{return id;}
set{id = value;}
} public ArithmeticClass Arithmetic
{
get{return arithmetic;}
set{arithmetic = value;}
} public TestClassName()
{
}
}
}
另一个是需要访问的类,即想根据 ArithmeticClass类型去访问的类using System;namespace Entity
{
/// <summary>
/// ArithmeticClass 的摘要说明。
/// </summary>
public class ArithmeticClass
{
private Guid arith; public ArithmeticClass()
{
this.arith = Guid.NewGuid();
} public void SetArith()
{
this.arith = Guid.NewGuid().ToString();
} public Guid GetArith()
{
return arith;
}
}
}
配置文件的名字是 TestClassName.hbm.xml
<property name="Arithmetic"
 type="Entity.ArithmeticClass,Entity">
 <column name="Arith" sql-type="nvarchar" not-null="true"/>
</property>
可总抱不能访问类型或不知道类型名:Entity.ArithmeticClass,Entity郁闷中。求高手赐教。