/// <summary> /// Get the root entity type in criteria /// </summary> /// <param name="detachedCriteria"></param> /// <param name="session"></param> /// <returns></returns> public static Type GetRootType(this DetachedCriteria detachedCriteria, ISession session) { // NOTE : NHibernate 2.1.0 과 2.0.1 GA에서 차이가 나서 그렇다. // for NH 2.1.0 var rootType = detachedCriteria.GetRootEntityTypeIfAvailable(); // for NH 2.0.1 // Type rootType = detachedCriteria.CriteriaClass; if (rootType != null) { return(rootType); } var factory = (ISessionFactoryImplementor)session.SessionFactory; // for NH 2.1.0 var persister = factory.GetEntityPersister(detachedCriteria.EntityOrClassName); Guard.Assert(persister != null, "Could not find entity named: " + detachedCriteria.EntityOrClassName); // for NH 2.0.1 //IEntityPersister persister = factory.GetEntityPersister(detachedCriteria.CriteriaClass.FullName); //Guard.Assert(persister != null, "Could not find entity named: " + detachedCriteria.CriteriaClass.FullName); return(persister.GetMappedClass(EntityMode.Poco)); }
private void EnsureRootTypeIsAvailable(DetachedCriteria criteria) { if (rootType == null) { rootType = criteria.GetRootEntityTypeIfAvailable(); } }
public static Type GetRootType(DetachedCriteria criteria, ISession session) { Type rootType = criteria.GetRootEntityTypeIfAvailable(); if (rootType != null) { return rootType; } ISessionFactoryImplementor factory = (ISessionFactoryImplementor)session.SessionFactory; IEntityPersister persister = factory.GetEntityPersister(criteria.EntityOrClassName); if (persister == null) throw new InvalidOperationException("Could not find entity named: " + criteria.EntityOrClassName); return persister.GetMappedClass(EntityMode.Poco); }
public static Type GetRootType(DetachedCriteria criteria, ISession session) { Type rootType = criteria.GetRootEntityTypeIfAvailable(); if (rootType != null) { return(rootType); } ISessionFactoryImplementor factory = (ISessionFactoryImplementor)session.SessionFactory; IEntityPersister persister = factory.GetEntityPersister(criteria.EntityOrClassName); if (persister == null) { throw new InvalidOperationException("Could not find entity named: " + criteria.EntityOrClassName); } return(persister.GetMappedClass(EntityMode.Poco)); }
private string GetSecurityKeyProperty(DetachedCriteria criteria) { Type rootType = criteria.GetRootEntityTypeIfAvailable(); return(criteria.Alias + "." + Security.GetSecurityKeyProperty(rootType)); }
public System.Type GetRootEntityTypeIfAvailable() { return(detachedCriteria.GetRootEntityTypeIfAvailable()); }
private string GetSecurityKeyProperty(DetachedCriteria criteria) { Type rootType = criteria.GetRootEntityTypeIfAvailable(); return criteria.Alias + "." + Security.GetSecurityKeyProperty(rootType); }