views:

139

answers:

1

Hi all!

We are using NHibernate as our ORM framework. We have a need to persist classes we load at run time. We do that according to metadata they come with, that holds names and types of the data they have. In order to build the tables for them at run time, we use the SchemaExport class from the NHibernate ToolSet API.

We wanted to ask two questions:

  1. Is there a way to make NHibernate do all the actual creations in one roundtrip to the DB instead of a roundtrip per table?
  2. In order to use the SchemaExport tool are building a dynamic string that represents a mapping file from a template we keep. Is there a better way to do this? Maybe even without a mapping string?
A: 

Ad 2. If I understand you correctly, you don't want to use hbm mappings, right? Have you considered using Fluent NHibernate? (http://fluentnhibernate.org/)

maciejkow
I don't want to reference NHibernate anywhere in my code (I'm using an abstract data access layer, that loads NHibernate dynamically on run time). The mapping files for the other classes I have are ok.The problem is just with the ones I load on run time, these need a table that is not yet in the DB and I want to avoid attaching a hbm.xml file to them.
So FluentNHibernate with AutoMapping conventions is definitely something you should look into.
maciejkow