Mapping by code, export generated hbm files

199 views
Skip to first unread message

Richard Wilde

unread,
Jun 10, 2011, 2:17:58 AM6/10/11
to nhusers
Hi I am playing with NH 3.2 and mapping by code. I have got it up and
running and all works great (in fact I quite like this syntax),
however I am trying to work out how I export the hbm generated
mappings into files so I can see what has been put together. In Fluent
Nhibernate I could call ExportTo...

var mapper = new ModelMapper();
mapper.AddMappings(typeof(ActorMapping).Assembly.GetTypes());

var configure = new Configuration();
configure.DataBaseIntegration(x =>
{
x.Dialect<MsSql2008Dialect>();
x.ConnectionStringName = "db";
});

configure.AddDeserializedMapping(mapper.CompileMappingForAllExplicitAddedEntities(),
"Domain");

Can anyone point me in the right direction
Many thanks.

Maximilian Raditya

unread,
Jun 10, 2011, 2:36:21 AM6/10/11
to nhu...@googlegroups.com
You can go on starting from here:
 
var mapping = mapper.CompileMappingForAllExplicitAddedEntities(), "Domain");
var xmlMapping = mapping.AsString(); // It's an extension method defined in NHibernate.Mapping.ByCode.MappingsExtensions
 
Then you can transform xmlMapping into whatever you need, e.g.: clipboard, file, etc., even while you're debugging :D.
 
 
 
 
--
Regards,

Maximilian Haru Raditya
 
 
 


 

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.




Richard Wilde

unread,
Jun 10, 2011, 2:42:11 AM6/10/11
to nhusers
Many thanks Maximillian, I had jumped one step to far....

Fabio Maulo

unread,
Jun 11, 2011, 2:00:53 PM6/11/11
to nhu...@googlegroups.com
There is even another extension:
public static void WriteAllXmlMapping(this IEnumerable<HbmMapping> mappings)
It will write a .hbm.xml file for each class in a folder named "Mappings"
Reply all
Reply to author
Forward
0 new messages