Tutorial :Fluent Nhibernate and pluggable inheritance



Question:

Is there any way to define/expand inheritance without changing base table mapping with Fluent NHibernate? For example with Castle.ActiveRecord (based on NHibernate) you can define inheritance like this:

[ActiveRecord("entity"), JoinedBase]  public class Entity : ActiveRecordBase  {       [PrimaryKey]      public int Id { get; set; }  }    [ActiveRecord("entitycompany")]  public class CompanyEntity : Entity  {      [JoinedKey("comp_id")]      public int CompId { get; set; }  }  
  • It's possible to add or remove new subclasses without changing base entity mappings.
  • When we call Entity.FindAll() it returns all entities (also those inherited).


Solution:1

Not right now, no. Certainly not in any way that will require no modifications to your parent class map.


Solution:2

Ok, I've found the way, it's possible by using IClassConvention + IOC(structuremap with assembly scanning).


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »