public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			if (projection != null)
			{
				return projection.GetTypes(criteria, criteriaQuery);
			}
			return new IType[] {criteriaQuery.GetType(criteria, propertyName)};
		}
 public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery)
 {
     if (projection != null)
     {
         return(projection.GetTypes(criteria, criteriaQuery));
     }
     return(new IType[] { criteriaQuery.GetType(criteria, propertyName) });
 }
        private void SetFields(ICriteriaQuery criteriaQuery)
        {
            //Persister is required, so let's use it as "initialized marker"
            if (Persister != null)
            {
                return;
            }

            if (!(criteriaQuery is ISupportEntityProjectionCriteriaQuery entityProjectionQuery))
            {
                throw new ArgumentException(
                          $"Projecting to entities requires a '{criteriaQuery.GetType().FullName}' type to implement " +
                          $"{nameof(ISupportEntityProjectionCriteriaQuery)} interface.",
                          nameof(criteriaQuery));
            }

            var criteria = entityProjectionQuery.RootCriteria;

            if (!Lazy)
            {
                entityProjectionQuery.RegisterEntityProjection(this);
            }

            if (_entityType == null)
            {
                _entityType = criteria.GetRootEntityTypeIfAvailable();
            }

            if (_entityAlias == null)
            {
                _entityAlias = criteria.Alias;
            }

            Persister = criteriaQuery.Factory.GetEntityPersister(_entityType.FullName) as IQueryable;
            if (Persister == null)
            {
                throw new HibernateException($"Projecting to entities requires a '{typeof(IQueryable).FullName}' persister, '{_entityType.FullName}' does not have one.");
            }

            ICriteria subcriteria = criteria.GetCriteriaByAlias(_entityAlias);

            if (subcriteria == null)
            {
                throw new HibernateException($"Criteria\\QueryOver alias '{_entityAlias}' for entity projection is not found.");
            }

            TableAlias = criteriaQuery.GetSQLAlias(
                subcriteria,
                Persister.IdentifierPropertyName ?? string.Empty);

            ColumnAliasSuffix = BasicLoader.GenerateSuffix(criteriaQuery.GetIndexForAlias());

            _identifierColumnAliases = Persister.GetIdentifierAliases(ColumnAliasSuffix);

            _types = new IType[] { TypeFactory.ManyToOne(Persister.EntityName, true) };
        }
        public IType GetType(ICriteria subcriteria, string propertyName)
        {
            if (TryGetType(subcriteria, propertyName, out var resultType))
            {
                return(resultType);
            }

            if (outerQueryTranslator != null)
            {
                return(outerQueryTranslator.GetType(subcriteria, propertyName));
            }

            throw new QueryException("Could not find property " + propertyName);
        }
        public IType GetTypeUsingProjection(ICriteria subcriteria, string propertyName)
        {
            //first look for a reference to a projection alias
            IProjection projection = rootCriteria.Projection;

            IType[] projectionTypes = projection == null ? null : projection.GetTypes(propertyName, subcriteria, this);

            if (projectionTypes == null)
            {
                try
                {
                    //it does not refer to an alias of a projection,
                    //look for a property
                    return(GetType(subcriteria, propertyName));
                }
                catch (HibernateException)
                {
                    //not found in inner query , try the outer query
                    if (outerQueryTranslator != null)
                    {
                        return(outerQueryTranslator.GetType(subcriteria, propertyName));
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            else
            {
                if (projectionTypes.Length != 1)
                {
                    //should never happen, i think
                    throw new QueryException("not a single-length projection: " + propertyName);
                }
                return(projectionTypes[0]);
            }
        }
Пример #6
0
 public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery)
 {
     return(new IType[] { criteriaQuery.GetType(criteria, propertyName) });
 }
Пример #7
0
		public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			return new IType[] {criteriaQuery.GetType(criteria, propertyName)};
		}