Need dependency injection for your entities? You got it. With
NHibernate 2.1, you can inject them through the constructors of your
entities, just like you do with all of your other objects.
public class Invoice : Entity
{
public Invoice(IInvoiceTotalCalculator calculator)
// Do stuff here
}
You just need a BytecodeProvider to do the DI. I've written one for
Ninject v2 and posted it on my blog here:
http://jasondentler.com/blog/2009/08/hibernating-ninjas-and-entity-ninjection-addin/
It can also easily be ported back to Ninject v1.
I'd appreciate all the comments and feedback you can give me.
Thanks,
Jason