sp; public DateTime DateCreated{
get { return dateCreated; }
set { dateCreated = value; }
}
}
}
XML文件(Course.hbm.xml)
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHibernateTest.Course, NHibernateTest" table="Course">
<id name="CourseId" column="CourseId" type="Int32">
<generator class="native" />
</id>
<property name="CourseName" column= "CourseName" type="string" length="40"/>
<property name="DateCreated" type="DateTime" length="8"/>
</class>
</hibernate-mapping>
(2) 含有关系的表的情况
含有关系的表指的是像学生这样,除了保存学生的基本信息,还希望把选课信息保存到学生的类中。这样情况下不能用软件来辅助产生对应的类和XML,这是NHibernate中唯一需要费脑筋学的地方。学生表对应的类和XML如下所示:
类文件(Student.cs)
using System;
using Iesi.Collections;
namespace CodeTest{
public class Student{
public Student(){}
private int studentId;
private string studentName;
private string studentPassword;
 
|