tags:

views:

26

answers:

1

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"

A: 
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.

SaD