Runtime in this context means _before_ we call BuildSessionFactory, but without touching the source XML files.
Ideally, I want to be able to run this at some point at the config build lifetime:
PersistentClass classMapping = cfg.GetClassMapping(userType);
foreach (PersistentClass persistentClass in cfg.ClassMappings)
{
//ignore non Rhino Security entities
if (persistentClass.MappedClass.Assembly != typeof(IUser).Assembly)
continue;
foreach (Property property in persistentClass.PropertyIterator)
{
ManyToOne manyToOne = property.Value as ManyToOne;
if (manyToOne == null || manyToOne.ReferencedEntityName != typeof(IUser).FullName)
continue;
ManyToOne value = new ManyToOne(classMapping.Table);
value.ReferencedEntityName = userType.FullName;
foreach (ISelectable selectable in manyToOne.ColumnIterator)
{
Column col = selectable as Column;
if (col != null)
{
value.AddColumn(col);
}
}
property.Value = value;
Collection collection = property.Value as Collection;
if (collection == null || collection.IsOneToMany ||
collection.GenericArguments.Length != 1 ||
collection.GenericArguments[0] != typeof(IUser))
continue;
IValue element = collection.Element;
}
foreach (ForeignKey key in persistentClass.Table.ForeignKeyIterator)
{
if (key.ReferencedEntityName != typeof(IUser).FullName)
continue;
key.ReferencedEntityName = userType.FullName;
key.ReferencedTable = classMapping.Table;
}
}
On Sun, Jun 29, 2008 at 5:09 PM, Fabio Maulo <
fabiomaulo@gmail.com> wrote:
I am _not_ interested in changing the XML. I am interested in selecting, at runtime, what is the class of the many-to-many association.
There is a difference between them
At run-time ok; but when ?
You know, NH do the hard work of mapping at build-session-factory-time.
So far only using <any> you can have an association really resolved at run-time.
I need to understand what you are looking for to study the situation.
--
Fabio Maulo
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development