Generate HBM files using mapping by code?

Up vote 0 down vote favorite share g+ share fb share tw.

I'm using NHibernate mapping by code and I'm creating the session factory in this way: var mapper = new ModelMapper(); mapper. AddMappings(Assembly. GetExecutingAssembly().

GetExportedTypes()); HbmMapping domainMapping = mapper. CompileMappingForAllExplicitlyAddedEntities(); const bool executeScript = false; var configuration = new Configuration(); configuration. DataBaseIntegration(c => { c.Dialect(); c.

ConnectionString = ConfigurationManager. ConnectionStrings"ShopConnectionString" . ConnectionString; c.

KeywordsAutoImport = Hbm2DDLKeyWords. AutoQuote; }); configuration. AddMapping(domainMapping); _sessionFactory = configuration.

BuildSessionFactory(); I need to get the corresponding HBM files. How can I achieve that? Nhibernate nhibernate-mapping link|improve this question asked Dec 29 '11 at 14:34Be.St.61612.

Thank you, I extract the mapping portion to a new method that return an HbmMapping object. So I'm able to use it and call AsString in a unit test. – URL1. Dec 29 '11 at 16:13 No worries, perhaps you can mark the correct answer as "correct".

– Rippo Dec 30 '11 at 10:24.

Two ways:- //This will write all the XML into the bin/mappings folder mapper. CompileMappingForEachExplicitlyAddedEntity(). WriteAllXmlMapping(); be careful of this method above as your asp.net app will recycle as changes are detected in your bin folder, another way is:- var mapping = mapper.

CompileMappingForAllExplicitlyAddedEntities(); //you could add a breakpoint here! Var mappingXml = mapping.AsString().

Use the AsString() extension method: domainMapping.AsString() It will give you the xml which you can save into a file. You can call that method e.g. Before you build the SessionFactory.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions