| 
					
						 Hi,
  I would like to "extend" my domain classes without having to add data to the domain classes themselves. Concider I have the following class:
  public class Person { public virtual int Id { get; private set; } public virtual string Name { get; set; } }
  And I have the following table in the database:
  tblPersons --------------- Id integer Name varchar(50) CreatedBy varchar(50) CreatedDate datetime
  So I don't want to add "CreatedBy" and "CreatedDate" to my domain class, because this has nothing to do with the actual domain itself...
  Would it be possible to get this data whenever I load an entity? I would like to use it like this:
  Person person = session.Load(1);
  person.CreatedBy(); <-- CreatedBy is an Extension function... doesn't really matter how I access the CreatedBy value... as long as I don't have to add it to the Person class person.CreatedDate(); <-- CreatedDate is an Extension function... doesn't really matter how I access the CreatedDate value... as long as I don't have to add it to the Person class
  Can anyone point me in which direction to go in order to implement this?
  I have thought about the following possibilities:
      * Implementa a custom ProxyFactory, where I inject a custom "interface" such as IUpdateable, howver it seems like NHibernate doesn't create the proxies consistently, sometimes it loads a my "proxy class" class, and sometimes it loads the "normal class":
  Person person = session.Load(2); //this will load my Proxy class of Person just fine
  Address address = person.Address; //Somehow this doesn't load a Proxy for Address, but instead loads it normally - seems like it's evaluating "ImmediateLoad", which doesn't load proxies, due to lazy loading... not sure how to make this behave as I want.
      *Using a custom PropertyAccessor, I have read something about this - but it seems I must actually map this to a property that EXITS on the domain class... so that wouldn't work right?
      *Just as NHibernate "injects" code to the runtime when creating the Proxy classes - perhaps I could do the same but inject the "interface" to the original Person class instead?
  Would appreciate any help on this, thank you! :) 
					
  
						
					 |