NHibernate Entity Dependency Ninjection

30 views
Skip to first unread message

Jason Dentler

unread,
Aug 7, 2009, 8:58:30 PM8/7/09
to ninject
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
Reply all
Reply to author
Forward
0 new messages