nservicebus5 - NServiceBus 5.2 Nhibernate fluent mapping -
please help? nservicebus endpoint is:
public class endpointconfig : iconfigurethisendpoint { public void customize(busconfiguration busconfiguration) { var windsorcontainer = new windsorcontainer(); windsorcontainer.install(new iocinstaller()); busconfiguration.usecontainer<windsorbuilder>(x => x.existingcontainer(windsorcontainer)); var nhconfiguration = new nhibernate.cfg.configuration(); nhconfiguration.properties["connection.provider"] = "nhibernate.connection.driverconnectionprovider"; nhconfiguration.properties["connection.driver_class"] = "nhibernate.driver.sql2008clientdriver"; nhconfiguration.properties["dialect"] = "nhibernate.dialect.mssql2008dialect"; nhconfiguration.getclassmapping(typeof(productachievementmap)); busconfiguration.usepersistence<nhibernatepersistence>().useconfiguration(nhconfiguration); busconfiguration.useserialization<xmlserializer>(); } }
my handler is:
public class productachievementauditcommandhandler : ihandlemessages<productachievementauditcommand> { public isession session { get; set; } public void handle(productachievementauditcommand message) { var productachievementaudit = new productachievement { id = guid.newguid(), sapcomid = message.sapcomid, messageid = message.messageid }; session.save(productachievementaudit); } }
my fluent mapping is:
public class productachievementmap : classmap<productachievement> { public productachievementmap() { table("productachievementmessage"); id(x => x.id); map(x => x.sapcomid); map(x => x.messageid); } }
the error i'm getting is:"error nservicebus.generichost exception when starting endpoint. system.invalidoperationexception: no nhibernate properties found in config". according documentation need use busconfiguration.usepersistence<nhibernatepersistence>().registermanagedsessioninthecontainer();
. public isession session { get; set; }
in handler. how fluent mapping work? appreciated.
i figured out hooray!! key changes in syntax in nservicebus 5.2 not sure if best way works. endpoint config looks this.
public class endpointconfig : iconfigurethisendpoint { public void customize(busconfiguration busconfiguration) { var nhconfiguration = new configuration(); nhconfiguration.properties["connection.provider"] = "nhibernate.connection.driverconnectionprovider"; nhconfiguration.properties["connection.driver_class"] = "nhibernate.driver.sql2008clientdriver"; nhconfiguration.properties["dialect"] = "nhibernate.dialect.mssql2008dialect"; nhconfiguration.properties["connection.connection_string"] = @"data source=sql_dev\development;initial catalog=spm.auditlog;integrated security=true"; var newconfig = fluently.configure(nhconfiguration) .mappings(x => { x.fluentmappings.addfromassemblyof<productachievementmap>(); }).buildconfiguration(); busconfiguration.usepersistence<nhibernatepersistence>().useconfiguration(newconfig); busconfiguration.usepersistence<nhibernatepersistence>().registermanagedsessioninthecontainer(); var windsorcontainer = new windsorcontainer(); windsorcontainer.install(new iocinstaller()); busconfiguration.usecontainer<windsorbuilder>(x => x.existingcontainer(windsorcontainer)); busconfiguration.useserialization<xmlserializer>(); } }
Comments
Post a Comment