Select from parent table return ID = 0 column values for child objects
- by SaD
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 table
1 item in Employee table
(1 in base class, 1 in child class)
Query:var list = Session.CreateQuery("from Person").List<Person>();
Return:
0 | ID = 1
1 | ID = 0, Appointment = "SomeAppointment"