/// <summary>
        /// Converts the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        protected ExpressionConversionResult Convert(ExpressionConversionResult source)
        {
            this.result = new ExpressionConversionResult(source);
            Expression expression = this.Visit(source.Expression);

            this.result.SetResultExpression(expression);
            return(this.result);
        }
        /// <summary>
        /// Converts the specified expression.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="annotations">The annotations.</param>
        /// <param name="metadataMapping">The metadata mapping.</param>
        /// <returns></returns>
        public static ExpressionConversionResult Convert(Expression expression, ExpressionResourceAnnotations annotations, DSPMetadata metadataMapping)
        {
            Debug.Assert(annotations != null, "annotations != null");
            Debug.Assert(metadataMapping != null, "metadataMapping != null");

            expression = ResourceAnnotationVisitor.Convert(expression, annotations);

            ExpressionConversionResult result = ConvertInnerExpression(expression, annotations, metadataMapping);

            expression = ExpressionSimplifier.Simplify(result.Expression);

            result.SetResultExpression(expression);
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Returns an enumerator that iterates through the collection.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Collections.Generic.IEnumerator`1"></see> that can be used to iterate through the collection.
        /// </returns>
        public IEnumerator <T> GetEnumerator()
        {
            ExpressionConversionResult result = this.queryProvider.ConvertExpression(this.queryExpression);

            IQueryable query = this.queryProvider.CreateSourceQuery(result.Expression);

            if (this.queryProvider.Context.DbEntityProvider.Log != null)
            {
                this.queryProvider.Context.DbEntityProvider.Log.WriteLine("DSPIQALinqQuery Underlying: {0}", query.ToString());
                Trace.WriteLine("Underlying: " + query.ToString());
            }

            return((IEnumerator <T>)query.GetEnumerator());
        }
        /// <summary>
        /// Converts the inner expression.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="annotations">The annotations.</param>
        /// <param name="contextMapping">The context mapping.</param>
        /// <returns></returns>
        private static ExpressionConversionResult ConvertInnerExpression(
            Expression expression,
            ExpressionResourceAnnotations annotations,
            DSPMetadata contextMapping)
        {
            Debug.Assert(expression != null, "expression != null");
            Debug.Assert(annotations != null, "annotations != null");
            Debug.Assert(contextMapping != null, "contextMapping != null");

            ExpressionConversionResult result = new ExpressionConversionResult(expression);

            FilterConverter filterConverter = new FilterConverter(annotations, contextMapping);

            result = filterConverter.Convert(result);

            return(result);
        }
        /// <summary>
        /// Converts the expression.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <returns></returns>
        internal ExpressionConversionResult ConvertExpression(Expression expression)
        {
            if (this.context.DbEntityProvider.Log != null)
            {
                this.context.DbEntityProvider.Log.WriteLine("ConvertExpression Before: {0}", expression.ToString());
                Trace.WriteLine("Before: " + expression.ToString());
            }

            ExpressionConversionResult result = ExpressionConverter.Convert(expression, this.ExpressionAnnotations, this.Context.ContextMapping);

            if (this.context.DbEntityProvider.Log != null)
            {
                this.context.DbEntityProvider.Log.WriteLine("ConvertExpression After: {0}", result.Expression.ToString());
                Trace.WriteLine("After: " + result.Expression.ToString());
            }
            return(result);
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionConversionResult"/> class.
 /// </summary>
 /// <param name="source">The source.</param>
 public ExpressionConversionResult(ExpressionConversionResult source)
 {
     this.expression            = source.expression;
     this.queryResultsProcessor = source.queryResultsProcessor;
 }