Fluent NHibernate: Example of a one-to-many relationship on an abstract class of a table-per-subclas
        Posted  
        
            by BigTommy79
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by BigTommy79
        
        
        
        Published on 2010-06-14T15:28:23Z
        Indexed on 
            2010/06/14
            15:42 UTC
        
        
        Read the original article
        Hit count: 268
        
Hi All,
I've been trying for ages to find an example (because I can't get it to work myself) of the correct mapping for a one-to-many relationship on an abstract class of a table-per-subclass implementation, in fluent nHibernate.
An example below: I'm looking to map the list of Fines on the Debt abstract base class to the Fine class.
if anyone knows of any tutorial or example they've come across before please let me know.
Thanks, Tim
public abstract class Entity
{
    public int Id { get; set; }
}
public abstract class Debt : Entity
{        
    public decimal Balance { get; set; }
    public IList<Fine> Fines { get; set; }
    public Debt()
    {
        Fines = new List<Fine>();
    }
}
public class CarLoan : Debt
{
}
public class CreditCard : Debt
{
}
public class LoanApplication : Entity
{
    public IList<Debt> ExistingDebts { get; set; }
    public LoanApplication()
    {
        ExistingDebts = new List<Debt>();
    }
}
public class Fine
{
    public Int64 Cash { get; set; }
}
        © Stack Overflow or respective owner