Exemple #1
0
        /// <summary>
        /// Gets an <see cref="IStreamedDataInfo"/> object describing the data streaming out of this <see cref="QueryModel"/>. If a query ends with
        /// the <see cref="SelectClause"/>, this corresponds to <see cref="Clauses.SelectClause.GetOutputDataInfo"/>. If a query has
        /// <see cref="QueryModel.ResultOperators"/>, the data is further modified by those operators.
        /// </summary>
        /// <returns>Gets a <see cref="IStreamedDataInfo"/> object describing the data streaming out of this <see cref="QueryModel"/>.</returns>
        /// <remarks>
        /// The data streamed from a <see cref="QueryModel"/> is often of type <see cref="IQueryable{T}"/> instantiated
        /// with a specific item type, unless the
        /// query ends with a <see cref="ResultOperatorBase"/>. For example, if the query ends with a <see cref="CountResultOperator"/>, the
        /// result type will be <see cref="int"/>.
        /// </remarks>
        /// <exception cref="InvalidOperationException">
        /// The <see cref="ResultTypeOverride"/> is not compatible with the calculated <see cref="IStreamedDataInfo"/> calculated from the <see cref="ResultOperators"/>.
        /// </exception>
        public IStreamedDataInfo GetOutputDataInfo()
        {
            var outputDataInfo = ResultOperators
                                 .Aggregate((IStreamedDataInfo)SelectClause.GetOutputDataInfo(), (current, resultOperator) => resultOperator.GetOutputDataInfo(current));

            if (ResultTypeOverride == null)
            {
                return(outputDataInfo);
            }

            try
            {
                return(outputDataInfo.AdjustDataType(ResultTypeOverride));
            }
            catch (Exception ex)
            {
                var resultTypeOverride = ResultTypeOverride;
                ResultTypeOverride = null;
                throw new InvalidOperationException(
                          string.Format(
                              "The query model's result type cannot be changed to '{0}'. The result type may only be overridden and set to values compatible with the ResultOperators' current data type ('{1}').",
                              resultTypeOverride,
                              outputDataInfo.DataType),
                          ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets an <see cref="IStreamedDataInfo"/> object describing the data streaming out of this <see cref="QueryModel"/>. If a query ends with
        /// the <see cref="SelectClause"/>, this corresponds to <see cref="Clauses.SelectClause.GetOutputDataInfo"/>. If a query has
        /// <see cref="QueryModel.ResultOperators"/>, the data is further modified by those operators.
        /// </summary>
        /// <returns>Gets a <see cref="IStreamedDataInfo"/> object describing the data streaming out of this <see cref="QueryModel"/>.</returns>
        /// <remarks>
        /// The data streamed from a <see cref="QueryModel"/> is often of type <see cref="IQueryable{T}"/> instantiated
        /// with a specific item type, unless the
        /// query ends with a <see cref="ResultOperatorBase"/>. For example, if the query ends with a <see cref="CountResultOperator"/>, the
        /// result type will be <see cref="int"/>.
        /// </remarks>
        public IStreamedDataInfo GetOutputDataInfo()
        {
            var outputDataInfo = ResultOperators
                                 .Aggregate((IStreamedDataInfo)SelectClause.GetOutputDataInfo(), (current, resultOperator) => resultOperator.GetOutputDataInfo(current));

            if (ResultTypeOverride != null)
            {
                return(outputDataInfo.AdjustDataType(ResultTypeOverride));
            }
            else
            {
                return(outputDataInfo);
            }
        }