tags:

views:

28

answers:

1

My C# project has repositories that are instantiated using dependency injection.

One of the repository methods needs access to the NHibernate.Cfg.Configuration instance (to generate the database schema) that was returned when initializing NHibernate.

I cannot pass the configuration to the repository however, because that would break the persistence ignorance principle -- I really don't want to expose any implementation details through the repository interface.

So what I'm looking for is a way of getting hold of the current NHibernate.Cfg.Configuration instance from within my repository. I have no trouble getting hold of the current session, it's just the configuration that I cannot get hold of.

+1  A: 

It is not possible. The SessionFactory does not keep any references to the Configuration that built it.

Anyway, as Mauricio said: schema generation is not a Repository concern.

Diego Mijelshon