In a project that I am working on, I have the following entities: Analyst, Client and Contractor. Each inherit from a base class User.
public abstract class User {
public virtual int Id { get; set; }
public virtual string Username { get; set; }
public virtual string FullName { get; set; }
}
I then have the other classes inheriting from the base class as:
public class Analyst : User {
// Empty class. There are no additional properties for an analyst.
}
public class Client : User {
// Empty class. There are no additional properties for a client.
}
public class Contractor : User {
public int TotalJobs { get; set; }
public int JobsInProgress { get; set; }
}
For the above classes, I have the following table structure:
USER
----
UserId
Username
FullName
UserType (1 = Analyst, 2 = Client, 3 = Contractor)
CONTRACTOR
----------
UserId
TotalJobs
JobsInProgress
There are no tables for Analyst and Client classes.
I would like to know how I can write the NHibernate mapping file for the Contractor class. For the other classes, I have created a User mapping file and added Client and Analyst as sub-classes. How can I map the Contractor class?