private ICriteriaInfoProvider GetPathInfo(string path) { StringTokenizer tokens = new StringTokenizer(path, ".", false); string componentPath = string.Empty; // start with the 'rootProvider' ICriteriaInfoProvider provider; if (nameCriteriaInfoMap.TryGetValue(rootEntityName, out provider) == false) { throw new ArgumentException("Could not find ICriteriaInfoProvider for: " + path); } foreach (string token in tokens) { componentPath += token; logger.DebugFormat("searching for {0}", componentPath); IType type = provider.GetType(componentPath); if (type.IsAssociationType) { // CollectionTypes are always also AssociationTypes - but there's not always an associated entity... IAssociationType atype = (IAssociationType)type; CollectionType ctype = type.IsCollectionType ? (CollectionType)type : null; IType elementType = (ctype != null) ? ctype.GetElementType(sessionFactory) : null; // is the association a collection of components or value-types? (i.e a colloction of valued types?) if (ctype != null && elementType.IsComponentType) { provider = new ComponentCollectionCriteriaInfoProvider(helper.GetCollectionPersister(ctype.Role)); } else if (ctype != null && !elementType.IsEntityType) { provider = new ScalarCollectionCriteriaInfoProvider(helper, ctype.Role); } else { provider = new EntityCriteriaInfoProvider((NHibernate_Persister_Entity.IQueryable)sessionFactory.GetEntityPersister( atype.GetAssociatedEntityName( sessionFactory) )); } componentPath = string.Empty; } else if (type.IsComponentType) { componentPath += '.'; } else { throw new QueryException("not an association: " + componentPath); } } logger.DebugFormat("returning entity name={0} for path={1} class={2}", provider.Name, path, provider.GetType().Name); return(provider); }
private ICriteriaInfoProvider GetPathInfo(string path) { StringTokenizer tokens = new StringTokenizer(path, ".", false); string componentPath = string.Empty; // start with the 'rootProvider' ICriteriaInfoProvider provider; if (nameCriteriaInfoMap.TryGetValue(rootEntityName, out provider) == false) throw new ArgumentException("Could not find ICriteriaInfoProvider for: " + path); foreach (string token in tokens) { componentPath += token; logger.DebugFormat("searching for {0}", componentPath); IType type = provider.GetType(componentPath); if (type.IsAssociationType) { // CollectionTypes are always also AssociationTypes - but there's not always an associated entity... IAssociationType atype = (IAssociationType)type; CollectionType ctype = type.IsCollectionType ? (CollectionType)type : null; IType elementType = (ctype != null) ? ctype.GetElementType(sessionFactory) : null; // is the association a collection of components or value-types? (i.e a colloction of valued types?) if (ctype != null && elementType.IsComponentType) { provider = new ComponentCollectionCriteriaInfoProvider(helper.GetCollectionPersister(ctype.Role)); } else if (ctype != null && !elementType.IsEntityType) { provider = new ScalarCollectionCriteriaInfoProvider(helper, ctype.Role); } else { provider = new EntityCriteriaInfoProvider((NHibernate_Persister_Entity.IQueryable)sessionFactory.GetEntityPersister( atype.GetAssociatedEntityName( sessionFactory) )); } componentPath = string.Empty; } else if (type.IsComponentType) { componentPath += '.'; } else { throw new QueryException("not an association: " + componentPath); } } logger.DebugFormat("returning entity name={0} for path={1} class={2}", provider.Name, path, provider.GetType().Name); return provider; }
private ICriteriaInfoProvider GetPathInfo(string path, ICriteriaInfoProvider rootProvider) { var tokens = path.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries); // start with the root ICriteriaInfoProvider provider = rootProvider; if (tokens.Length == 0) { return(provider); } int i = 0; if (entityJoins.TryGetValue(tokens[0], out var entityJoinInfo)) { provider = new EntityCriteriaInfoProvider(entityJoinInfo.Persister); i++; } string componentPath = string.Empty; for (; i < tokens.Length; i++) { componentPath += tokens[i]; logger.Debug("searching for {0}", componentPath); IType type = provider.GetType(componentPath); if (type.IsAssociationType) { // CollectionTypes are always also AssociationTypes - but there's not always an associated entity... IAssociationType atype = (IAssociationType)type; CollectionType ctype = type.IsCollectionType ? (CollectionType)type : null; IType elementType = (ctype != null) ? ctype.GetElementType(sessionFactory) : null; // is the association a collection of components or value-types? (i.e a colloction of valued types?) if (ctype != null && elementType.IsComponentType) { provider = new ComponentCollectionCriteriaInfoProvider(helper.GetCollectionPersister(ctype.Role)); } else if (ctype != null && !elementType.IsEntityType) { provider = new ScalarCollectionCriteriaInfoProvider(helper, ctype.Role); } else { provider = new EntityCriteriaInfoProvider( GetQueryablePersister(atype.GetAssociatedEntityName(sessionFactory))); } componentPath = string.Empty; } else if (type.IsComponentType) { componentPath += '.'; } else { throw new QueryException("not an association: " + componentPath); } } logger.Debug("returning entity name={0} for path={1} class={2}", provider.Name, path, provider.GetType().Name); return(provider); }