private static System.Type GetRootType(CriteriaImpl criteria) { if (criteria.Session == null) { throw new InvalidOperationException("Could not get root type on criteria that is not attached to a session"); } ISessionFactoryImplementor factory = criteria.Session.Factory; //TODO: need to cache the entityName meta data var entityNames = factory.GetEntityNameMetaData(); if (!entityNames.ContainsKey(criteria.EntityOrClassName)) { throw new InvalidOperationException("Could not find entity named: " + criteria.EntityOrClassName); } return(entityNames[criteria.EntityOrClassName]); }