ich das selbst gelöst.
Da es unmöglich scheint, auf irgendeine Konfiguration in der ClassMap zuzugreifen (und ich wollte nicht beginnen, Config-Dateien dort manuell zu lesen) und da Sie keine Abhängigkeiten in der ClassMap über einige IoC-Framework (Classmaps müssen ein parameterlos Konstruktor), ich hatte es die "altmodische Weise" mit einer Singleton-Klasse zu tun:
die Singleton:
public class DefaultSchemaProvider { privater static DefaultSchemaProvider _instance = null; private Zeichenfolge _defaultSchema = null;
public static DefaultSchemaProvider Instance
{
get
{
if (_instance == null)
_instance = new DefaultSchemaProvider();
return _instance;
}
}
public void SetDefaultSchema(string defaultSchema)
{
_defaultSchema = defaultSchema;
}
public string GetDefaultSchema()
{
return _defaultSchema;
}
}
Während der Konfiguration:
var nhibernateCfg = new NHibernate.Cfg.Configuration();
nhibernateCfg.Configure(ConfigurationFile);
DefaultSchemaProvider.Instance.SetDefaultSchema(nhibernateCfg.GetProperty("default_schema"));
im classmap:
public class CustomerMap : ClassMap<Customer>
{
public CustomerMap()
{
var defaultSchema = DefaultSchemaProvider.Instance.GetDefaultSchema() + ".";
Table("Customers");
Id(x => x.Id).Column("Customer_id");
Map(x => x.Description).Column("Name");
Component(c => c.CustomerType, c =>
{
c.Map(x => x.Id).Column("Customer_type");
c.Map(x => x.Description).Formula(
"(SELECT ct.value FROM " + defaultSchema + "customer_types ct WHERE ct.field='description' AND ct.typeid = Customer_type)");
});
HasMany(x => x.ArticleLinks).KeyColumn("VENR").Access.CamelCaseField(Prefix.Underscore);
}
}
falls jemand hier kommt, ist es möglich, classmaps mit constructorparameters zu haben. 'var model = neues PersistenceModel(); model.Add (neue MyClassMap (irgendein Parameter)); Fließend ... Mappings (m => m.UsePersistenceModel (model) ...) ' – Firo