0
public class Person
{
public Person(){}
public virtual long ID { get; set; }
}
public class Employee : Person
{
public Employee(){}
public virtual long ID { get; set; }
public virtual string Appointment { get; set; }
}
映射:在Person表
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Id(x => x.ID)
.GeneratedBy.Identity();
}
}
public class EmployeeMap : SubclassMap<Employee>
{
public EmployeeMap()
{
KeyColumn("ID");
Map(x => x.Appointment)
.Not.Nullable()
.Length(50);
}
}
2項中的Employee表 1項(1基1級,兒童級)
查詢:var list = Session.CreateQuery("from Person").List<Person>();
返回:
0 | ID = 1
1 | ID = 0,Appointment =「Some Appointment」
請問您有什麼問題? – egrunin 2010-04-30 08:45:28