Fluent NHibernate, dynamically change Table of mapping?
- by Steffen
Hello,
with fluent nhibernate, is there a way to dynamically switch the table of a mapping at runtime?
For example:
public class XYClassMap : ClassMap<XY>
{
public XYClassMap( )
{
Table("XYTable");
Id(d => d.Id).GeneratedBy.Identity();
Map(d => d.Value);
(...)
Given that there are multiple plugins, each of them uses this one class, but they need to work with different tables. I am looking for something like this:
public class XY {
public string Tablename {get; set;}
}
public class XYClassMap : ClassMap<XY>
{
public XYClassMap( )
{
Table(Tablename);
Id(d => d.Id).GeneratedBy.Identity();
Map(d => d.Value);
(...)
So every action method could work with the same class and only would need to set this one property "Tablename".
Thanks for any help,
Steffen