//http://stackoverflow.com/questions/5229510/nhibernate-get-concrete-type-of-referenced-abstract-entity#5333880 public static object Unproxy(NHibernate.ISession session, IDataItem proxy) { if (!NHibernateUtil.IsInitialized(proxy)) { NHibernateUtil.Initialize(proxy); } if (proxy is NHibernate.Proxy.INHibernateProxy) { return(session.GetSessionImplementation().PersistenceContext.Unproxy(proxy)); } return(proxy); }