I'm trying to use NHibernate.Search on a SharpArchitecture app, with FluentNHibernate.Search mapping to maintain pure POCO domain objects.
But i dont know how to setup the NHibernateSession:
On my Global.asax.cs i have this initialization and works fine:
NHibernateSession.Init(
this.webSessionStorage,
new[] { Server.MapPath( "~/bin/MyBlog.Infrastructure.dll" ) },
new AutoPersistenceModelGenerator().Generate(),
Server.MapPath( "~/NHibernate.config" ) );
Then, https://github.com/trullock/Fluent-NHibernate-Search/wiki says that i need to create a FluentSearch config like this:
Configuration nhcfg = FluentSearch.Configure()
.DefaultAnalyzer().Standard()
.DirectoryProvider().FSDirectory()
.IndexBase("~/Index")
.IndexingStrategy().Event()
.MappingClass<LibrarySearchMapping>()
.BuildConfiguration();
And finally configure NHibernate.Search atop FluentNHibernate.
But, what can i do to connect "nhcfg" config with NHibernateSession.Init? NHibernateSession.Init and FluentHibernate.Search appear to have incompatible interfaces.
Is there a way to integrate NHibernate.Search on a SharpArchitecture app with FluentHibernate.Search mapping?
Solved!
I have looked inside NHibernateSesssion implementation from SharpArchitecture and extracted the session factory configuration outside NHibernateSession.Init method. Finally i have added the new configuration calling NHibernateSession.AddConfiguration method.
Pay attention that NHibernateSession.Init internally register some listeners:
The problems is that DataAnnotationsEventListener class, is internal to SharpArch.NHibernate.dll; so i need to duplicate this class inside my project. Ugly but works.
Finally NHibernate session initialization look like this: