/// <summary>
        /// Composes the <paramref name="previous"/> expression with this one when it's specified multiple times.
        /// </summary>
        /// <param name="previous"><see cref="QueryOptionExpression"/> to compose.</param>
        /// <returns>
        /// The expression that results from composing the <paramref name="previous"/> expression with this one.
        /// </returns>
        internal override QueryOptionExpression ComposeMultipleSpecification(QueryOptionExpression previous)
        {
            Debug.Assert(previous != null, "other != null");
            Debug.Assert(previous.GetType() == this.GetType(), "other.GetType == this.GetType() -- otherwise it's not the same specification");
            Debug.Assert(this.skipAmount != null, "this.skipAmount != null");
            Debug.Assert(
                this.skipAmount.Type == typeof(int),
                "this.skipAmount.Type == typeof(int) -- otherwise it wouldn't have matched the Enumerable.Skip(source, int count) signature");
            int thisValue     = (int)this.skipAmount.Value;
            int previousValue = (int)((SkipQueryOptionExpression)previous).skipAmount.Value;

            return(new SkipQueryOptionExpression(this.Type, Expression.Constant(thisValue + previousValue, typeof(int))));
        }
예제 #2
0
 /// <summary>
 /// Composes the <paramref name="previous"/> expression with this one when it's specified multiple times.
 /// </summary>
 /// <param name="previous"><see cref="QueryOptionExpression"/> to compose.</param>
 /// <returns>
 /// The expression that results from composing the <paramref name="previous"/> expression with this one.
 /// </returns>
 internal virtual QueryOptionExpression ComposeMultipleSpecification(QueryOptionExpression previous)
 {
     Debug.Assert(previous != null, "other != null");
     Debug.Assert(previous.GetType() == this.GetType(), "other.GetType == this.GetType() -- otherwise it's not the same specification");
     return(this);
 }
        /// <summary>
        /// Add query option to resource expression
        /// </summary>
        /// <param name="qoe">The query option expression.</param>
        internal void AddSequenceQueryOption(QueryOptionExpression qoe)
        {
            Debug.Assert(qoe != null, "qoe != null");
            QueryOptionExpression old = this.sequenceQueryOptions.Where(o => o.GetType() == qoe.GetType()).FirstOrDefault();

            if (old != null)
            {
                qoe = qoe.ComposeMultipleSpecification(old);
                this.sequenceQueryOptions.Remove(old);
            }

            this.sequenceQueryOptions.Add(qoe);
        }