NHibernate的一个问题
我仿照Hibernate的中文手册做了一个 类,就使用了手册里里胡类Cat,类的结构如下:
public class Cat
{
public Cat()
{
}
private string catID;
private string sex;
private double weight;
dd private System.DateTime birthDay;
private Cat mate;
private IDictionary kittens = new Hashtable();
public string CatID
{
get {return catID;}
set {catID = value;}
}
public string Sex
{
get {return sex;}
set {sex = value;}
}
public double Weight
{
get {return weight;}
set {weight = value;}
}
public DateTime BirthDay
{
get {return birthDay;}
set {birthDay = value;}
}
public Cat Mate
{
get {return mate;}
set {mate = value;}
}
public IDictionary Kittens
{
get {return kittens;}
set {kittens = value;}
}
}
使用的映射文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="nhbDemo.BusinessEntity.Cat, nhbDemo" table="cats">
<id name="CatID" column="catid" type="String(40)">
<generator class="assigned" />
</id>
<property name="BirthDay" type="DateTime"/>
<property name="Weight" type="String(40)"/>
<property name="Sex" type="String(20)"/>
<many-to-one name="Mate" column="mate_id" class="nhbDemo.BusinessEntity.Cat, nhbDemo"/>
<set name="Kittens" table="cats">
<key column="parent_id"/>
<one-to-many class="nhbDemo.BusinessEntity.Cat, nhbDemo"/>
</set>
</class>
</hibernate-mapping>
数据库cats镖的结构如下:
sex
weight
catid 这是prime key
birthdy
mate_id
parent_id
然后我在page_load调用如下的代码:
IList catList = session.CreateCriteria(typeof(Cat)).List();
错误信息如下:
不能从目标类型扩展到基元类型
哪位大虾能帮我看看这是什莫问题!!!