How to configure "Windsor NHibernate Facility" by C# code, not xml?

818 Views Asked by At

i try to integrate Castle Windsor and Nhibernate Facility with my legacy old project recently, follow the doc(http://docs.castleproject.org/Windsor.NHibernate-Facility.ashx).

<facilities>
  <facility id="nhibernate" ...>
    <factory id="nhibernate.factory">
      ...
    </factory>

    <factory id="nhibernate.factory" alias="oracle2">
      ...
    </factory>
  </facility>
</facilities>

but i wonder if there is an way to configure the NHibernate SessionFactory by C# code, not in xml. the reason is:my old project configure the connection string in some other place, i cannot configure it in 2 places. i already successfully build my NHibernate Session Factory(3 databases, 3 factories), just need to inject my session factory object in the NHibernate Facility, give it an 'id' and 'alias', is it possible ? or any better idea?

thank you in advance !

1

There are 1 best solutions below

0
On

Have a look to mvc tutorial - persistence step