Using NHibernate IPreInsertEventListener and trying to find the mapped table
I am trying to implement a PreInsertEvent listener using the latest version (which was at the time of writing: 2.1.2.4000) of NHibernate. One of the things I want to do in this listener is find the database table that my entity will be displayed in. (Assuming this is just one table).
Does anyone know where in IEntityPersister I could find this?
source to share
The answer to this is in PreInsertEvent. Persister.PropertySpaces
public bool OnPreInsert(PreInsertEvent evt) {
for (var i = 0; i < evt.Persister.PropertySpaces.Length; i++)
{
Console.Out.WriteLine("\tevt.Persister.PropertySpaces = {0}", evt.Persister.PropertySpaces[i]);
}
}
From code base:
// Returns an array of objects that identify the whitespace in which the properties // of this object are stored, only for instances of this class.
// For most implementations, this returns the full set of table names
// to which instances of the mapped object are stored (not the credentials // for superclass entity mappings).
source to share