Fluent NHibernate, dynamically change Table of mapping?
Posted
by Steffen
on Stack Overflow
See other posts from Stack Overflow
or by Steffen
Published on 2010-02-18T17:02:24Z
Indexed on
2010/03/11
20:14 UTC
Read the original article
Hit count: 686
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
© Stack Overflow or respective owner