Select from parent table return ID = 0 column values for child objects
Entities:
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; }
}
Mappings:
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 items in Person tabl开发者_如何学编程e 1 item in Employee table (1 in base class, 1 in child class)
Query:var list = Session.CreateQuery("from Person").List<Person>();
public class Employee : Person
{
public Employee(){}
public virtual long ID { get; set; }
public virtual string Appointment { get; set; }
}
public virtual long ID { get; set; } - Not supposed to be here.
精彩评论