tags:

views:

52

answers:

2

I'm working on a project that requires me to load tables based on table names stored in another table. More tables will be added to the DB (and by someone else), so creating NHibernate mapping files for each table isn't an option.

Does anyone know if it is possible to load tables dynamically using NHibernate?

Edit: I should add that I'm on .NET 2.0, so I can't use Fluent NHibernate. Thanks for the suggestion though guys. I will use that as evidence in convincing my associates to upgrade.

A: 

I'm not a Fluent Nhibernate expert but I imagine that this would be perfect for it. It has an automapping feature...I imagine you could fire up a standard ADO.NET object grab the table names and loop through them mapping merrily as you go.

Webjedi
A: 

You could use fluent nHibernate to dynamically create the configurations you need.

You can also check out this post by one of the nHibernate devs while this doesn't show you how to do exactly what you want it. He is dynamically controlling the table names and column names in the mapping:

JoshBerke