RelationalExpressions.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Common / CommandTrees / RelationalExpressions.cs / 1305376 / RelationalExpressions.cs

                            //---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// 
// @owner  [....]
// @backupOwner [....] 
//--------------------------------------------------------------------- 

using System; 
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics;
 
using System.Data.Common;
using System.Data.Metadata.Edm; 
using System.Data.Common.CommandTrees.Internal; 

namespace System.Data.Common.CommandTrees 
{
    /// 
    /// Represents an apply operation, which is the invocation of the specified functor for each element in the specified input set.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbApplyExpression : DbExpression 
    { 
        private readonly DbExpressionBinding _input;
        private readonly DbExpressionBinding _apply; 

        internal DbApplyExpression(DbExpressionKind applyKind, TypeUsage resultRowCollectionTypeUsage, DbExpressionBinding input, DbExpressionBinding apply)
            : base(applyKind, resultRowCollectionTypeUsage)
        { 
            Debug.Assert(input != null, "DbApplyExpression input cannot be null");
            Debug.Assert(input != null, "DbApplyExpression apply cannot be null"); 
            Debug.Assert(DbExpressionKind.CrossApply == applyKind || DbExpressionKind.OuterApply == applyKind, "Invalid DbExpressionKind for DbApplyExpression"); 

            _input = input; 
            _apply = apply;
        }

        ///  
        /// Gets the  that specifies the functor that is invoked for each element in the input set.
        ///  
        public DbExpressionBinding Apply { get { return _apply;  } } 

        ///  
        /// Gets the  that specifies the input set.
        /// 
        public DbExpressionBinding Input { get { return _input; } }
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }

        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    }

    ///  
    /// Represents the removal of duplicate elements from the specified set operand.
    ///  
    ///  
    /// DbDistinctExpression requires that its argument has a collection result type
    /// with an element type that is equality comparable. 
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbDistinctExpression : DbUnaryExpression
    { 
        internal DbDistinctExpression(TypeUsage resultType, DbExpression argument)
            : base(DbExpressionKind.Distinct, resultType, argument) 
        { 
            Debug.Assert(TypeSemantics.IsCollectionType(argument.ResultType), "DbDistinctExpression argument must have a collection result type");
        } 

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
 
    /// 
    /// Represents the conversion of the specified set operand to a singleton.
    /// 
    ///  
    /// DbElementExpression requires that its argument has a collection result type
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbElementExpression : DbUnaryExpression
    { 
        private bool _singlePropertyUnwrapped;

        internal DbElementExpression(TypeUsage resultType, DbExpression argument)
            : base(DbExpressionKind.Element, resultType, argument) 
        {
            this._singlePropertyUnwrapped = false; 
        } 

        internal DbElementExpression(TypeUsage resultType, DbExpression argument, bool unwrapSingleProperty) 
            : base(DbExpressionKind.Element, resultType, argument)
        {
            this._singlePropertyUnwrapped = unwrapSingleProperty;
        } 

        ///  
        /// Is the result type of the element equal to the result type of the single property 
        /// of the element of its operand?
        ///  
        internal bool IsSinglePropertyUnwrapped { get { return _singlePropertyUnwrapped; } }

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        /// 
        /// An instance of DbExpressionVisitor. 
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by 
        ///  is null 
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    /// 
    /// Represents the set subtraction operation between the left and right operands.
    ///  
    /// 
    /// DbExceptExpression requires that its arguments have a common collection result type 
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbExceptExpression : DbBinaryExpression 
    {
        internal DbExceptExpression(TypeUsage resultType, DbExpression left, DbExpression right)
            : base(DbExpressionKind.Except, resultType, left, right)
        { 
            Debug.Assert(object.ReferenceEquals(resultType, left.ResultType), "DbExceptExpression result type should be result type of left argument");
        } 
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        /// 
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by 
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
 
    ///  
    /// Represents a predicate applied to an input set to produce the set of elements that satisfy the predicate.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbFilterExpression : DbExpression
    {
        private readonly DbExpressionBinding _input; 
        private readonly DbExpression _predicate;
 
        internal DbFilterExpression(TypeUsage resultType, DbExpressionBinding input, DbExpression predicate) 
            : base(DbExpressionKind.Filter, resultType)
        { 
            Debug.Assert(input != null, "DbFilterExpression input cannot be null");
            Debug.Assert(predicate != null, "DbBFilterExpression predicate cannot be null");
            Debug.Assert(TypeSemantics.IsPrimitiveType(predicate.ResultType, PrimitiveTypeKind.Boolean), "DbFilterExpression predicate must have a Boolean result type");
 
            _input = input;
            _predicate = predicate; 
        } 

        ///  
        /// Gets the  that specifies the input set.
        /// 
        public DbExpressionBinding Input { get { return _input; } }
 
        /// 
        /// Gets the  that specifies the predicate used to filter the input set. 
        ///  
        public DbExpression Predicate { get { return _predicate; } }
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value.
        /// 
        /// An instance of DbExpressionVisitor. 
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by 
        ///  is null 
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    } 

    ///  
    /// Represents a group by operation, which is a grouping of the elements in the input set based on the specified key expressions followed by the application of the specified aggregates.
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbGroupByExpression : DbExpression 
    {
        private readonly DbGroupExpressionBinding _input; 
        private readonly DbExpressionList _keys; 
        private readonly System.Collections.ObjectModel.ReadOnlyCollection _aggregates;
 
        internal DbGroupByExpression(TypeUsage collectionOfRowResultType,
                                     DbGroupExpressionBinding input,
                                     DbExpressionList groupKeys,
                                     System.Collections.ObjectModel.ReadOnlyCollection aggregates) 
            : base(DbExpressionKind.GroupBy, collectionOfRowResultType)
        { 
            Debug.Assert(input != null, "DbGroupExpression input cannot be null"); 
            Debug.Assert(groupKeys != null, "DbGroupExpression keys cannot be null");
            Debug.Assert(aggregates != null, "DbGroupExpression aggregates cannot be null"); 
            Debug.Assert(groupKeys.Count > 0 || aggregates.Count > 0, "At least one key or aggregate is required");

            _input = input;
            _keys = groupKeys; 
            _aggregates = aggregates;
        } 
 
        /// 
        /// Gets the  that specifies the input set and provides access to the set element and group element variables. 
        /// 
        public DbGroupExpressionBinding Input { get { return _input; } }

        ///  
        /// Gets an  list that provides grouping keys.
        ///  
        public IList Keys { get { return _keys; } } 

        ///  
        /// Gets an  list that provides the aggregates to apply.
        /// 
        public IList Aggregates { get { return _aggregates; } }
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }

        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    }

    ///  
    /// Represents the set intersection operation between the left and right operands.
    ///  
    ///  
    /// DbIntersectExpression requires that its arguments have a common collection result type
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbIntersectExpression : DbBinaryExpression
    {
        internal DbIntersectExpression(TypeUsage resultType, DbExpression left, DbExpression right) 
            : base(DbExpressionKind.Intersect, resultType, left, right)
        { 
        } 

        ///  
        /// The visitor pattern method for expression visitors that do not produce a result value.
        /// 
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        ///  
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by 
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 
 
    /// 
    /// Represents an unconditional join operation between the given collection arguments 
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbCrossJoinExpression : DbExpression
    { 
        private readonly System.Collections.ObjectModel.ReadOnlyCollection _inputs;
 
        internal DbCrossJoinExpression(TypeUsage collectionOfRowResultType, System.Collections.ObjectModel.ReadOnlyCollection inputs) 
            : base(DbExpressionKind.CrossJoin, collectionOfRowResultType)
       { 
           Debug.Assert(inputs != null, "DbCrossJoin inputs cannot be null");
           Debug.Assert(inputs.Count >= 2, "DbCrossJoin requires at least two inputs");

           _inputs = inputs; 
        }
 
        ///  
        /// Gets an  list that provide the input sets to the join.
        ///  
        public IList Inputs { get { return _inputs; } }

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        /// 
        /// An instance of DbExpressionVisitor. 
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by 
        ///  is null 
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    /// 
    /// Represents an inner, left outer or full outer join operation between the given collection arguments on the specified join condition.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbJoinExpression : DbExpression 
    { 
        private readonly DbExpressionBinding _left;
        private readonly DbExpressionBinding _right; 
        private readonly DbExpression _condition;

        internal DbJoinExpression(DbExpressionKind joinKind, TypeUsage collectionOfRowResultType, DbExpressionBinding left, DbExpressionBinding right, DbExpression condition)
            : base(joinKind, collectionOfRowResultType) 
        {
            Debug.Assert(left != null, "DbJoinExpression left cannot be null"); 
            Debug.Assert(right != null, "DbJoinExpression right cannot be null"); 
            Debug.Assert(condition != null, "DbJoinExpression condition cannot be null");
            Debug.Assert(DbExpressionKind.InnerJoin == joinKind || 
                         DbExpressionKind.LeftOuterJoin == joinKind ||
                         DbExpressionKind.FullOuterJoin == joinKind,
                         "Invalid DbExpressionKind specified for DbJoinExpression");
 
            _left = left;
            _right = right; 
            _condition = condition; 
        }
 
        /// 
        /// Gets the  provides the left input.
        /// 
        public DbExpressionBinding Left { get { return _left; } } 

        ///  
        /// Gets the  provides the right input. 
        /// 
        public DbExpressionBinding Right { get { return _right; } } 

        /// 
        /// Gets the  that defines the join condition to apply.
        ///  
        public DbExpression JoinCondition { get { return _condition; } }
 
        ///  
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        ///  
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    ///  
    /// Represents the restriction of the number of elements in the Argument collection to the specified Limit value. 
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbLimitExpression : DbExpression
    {
        private readonly DbExpression _argument;
        private readonly DbExpression _limit; 
        private readonly bool _withTies;
 
        internal DbLimitExpression(TypeUsage resultType, DbExpression argument, DbExpression limit, bool withTies) 
            : base(DbExpressionKind.Limit, resultType)
        { 
            Debug.Assert(argument != null, "DbLimitExpression argument cannot be null");
            Debug.Assert(limit != null, "DbLimitExpression limit cannot be null");
            Debug.Assert(object.ReferenceEquals(resultType, argument.ResultType), "DbLimitExpression result type must be the result type of the argument");
 
            this._argument = argument;
            this._limit = limit; 
            this._withTies = withTies; 
        }
 
        /// 
        /// Gets the expression that specifies the input collection.
        /// 
        public DbExpression Argument { get { return this._argument; } } 

        ///  
        /// Gets the expression that specifies the limit on the number of elements returned from the input collection. 
        /// 
        public DbExpression Limit { get { return this._limit; } } 

        /// 
        /// Gets whether the limit operation will include tied results, which could produce more results than specifed by the Limit value if ties are present.
        ///  
        public bool WithTies { get { return _withTies; } }
 
        ///  
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        ///  
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    ///  
    /// Represents the projection of a given set of values over the specified input set. 
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbProjectExpression : DbExpression
    {
        private readonly DbExpressionBinding _input;
        private readonly DbExpression _projection; 

        internal DbProjectExpression(TypeUsage resultType, DbExpressionBinding input, DbExpression projection) 
            : base(DbExpressionKind.Project, resultType) 
        {
            Debug.Assert(input != null, "DbProjectExpression input cannot be null"); 
            Debug.Assert(projection != null, "DbProjectExpression projection cannot be null");

            this._input = input;
            this._projection = projection; 
        }
 
        ///  
        /// Gets the  that specifies the input set.
        ///  
        public DbExpressionBinding Input { get { return _input; } }

        /// 
        /// Gets the  that defines the projection. 
        /// 
        public DbExpression Projection { get { return _projection; } } 
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        /// 
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by 
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
 
    ///  
    /// Represents a quantifier operation of the specified kind (Any, All) over the elements of the specified input set.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbQuantifierExpression : DbExpression
    {
        private readonly DbExpressionBinding _input; 
        private readonly DbExpression _predicate;
 
        internal DbQuantifierExpression(DbExpressionKind kind, TypeUsage booleanResultType, DbExpressionBinding input, DbExpression predicate) 
            : base(kind, booleanResultType)
        { 
            Debug.Assert(input != null, "DbQuantifierExpression input cannot be null");
            Debug.Assert(predicate != null, "DbQuantifierExpression predicate cannot be null");
            Debug.Assert(TypeSemantics.IsPrimitiveType(booleanResultType, PrimitiveTypeKind.Boolean), "DbQuantifierExpression must have a Boolean result type");
            Debug.Assert(TypeSemantics.IsPrimitiveType(predicate.ResultType, PrimitiveTypeKind.Boolean), "DbQuantifierExpression predicate must have a Boolean result type"); 

            this._input = input; 
            this._predicate = predicate; 
        }
 
        /// 
        /// Gets the  that specifies the input set.
        /// 
        public DbExpressionBinding Input { get { return _input; } } 

        ///  
        /// Gets the Boolean predicate that should be evaluated for each element in the input set. 
        /// 
        public DbExpression Predicate { get { return _predicate; } } 

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
 
    /// 
    /// Specifies a sort key that can be used as part of the sort order in a DbSortExpression.
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbSortClause
    { 
        private readonly DbExpression _expr; 
        private readonly bool _asc;
        private readonly string _coll; 

        internal DbSortClause(DbExpression key, bool asc, string collation)
        {
            Debug.Assert(key != null, "DbSortClause key cannot be null"); 

            _expr = key; 
            _asc = asc; 
            _coll = collation;
        } 

        /// 
        /// Gets a Boolean value indicating whether or not this sort key is sorted ascending.
        ///  
        public bool Ascending { get { return _asc; } }
 
        ///  
        /// Gets a string value that specifies the collation for this sort key.
        ///  
        public string Collation { get { return _coll; } }

        /// 
        /// Gets the  that provides the value for this sort key. 
        /// 
        public DbExpression Expression { get { return _expr; } } 
    } 

    ///  
    /// Represents a skip operation of the specified number of elements of the input set after the ordering described in the given sort keys is applied.
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbSkipExpression : DbExpression 
    {
        private readonly DbExpressionBinding _input; 
        private readonly System.Collections.ObjectModel.ReadOnlyCollection _keys; 
        private readonly DbExpression _count;
 
        internal DbSkipExpression(TypeUsage resultType, DbExpressionBinding input, System.Collections.ObjectModel.ReadOnlyCollection sortOrder, DbExpression count)
            : base(DbExpressionKind.Skip, resultType)
        {
            Debug.Assert(input != null, "DbSkipExpression input cannot be null"); 
            Debug.Assert(sortOrder != null, "DbSkipExpression sort order cannot be null");
            Debug.Assert(count != null, "DbSkipExpression count cannot be null"); 
            Debug.Assert(TypeSemantics.IsCollectionType(resultType), "DbSkipExpression requires a collection result type"); 

            this._input = input; 
            this._keys = sortOrder;
            this._count = count;
        }
 
        /// 
        /// Gets the  that specifies the input set. 
        ///  
        public DbExpressionBinding Input { get { return _input; } }
 
        /// 
        /// Gets a  list that defines the sort order.
        /// 
        public IList SortOrder { get { return _keys; } } 

        ///  
        /// Gets the expression that specifies the number of elements from the input collection to skip. 
        /// 
        public DbExpression Count 
        {
            get { return _count; }
        }
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }

        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    }

    ///  
    /// Represents a sort operation applied to the elements of the specified input set based on the given sort keys.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbSortExpression : DbExpression
    { 
        private readonly DbExpressionBinding _input;
        private readonly System.Collections.ObjectModel.ReadOnlyCollection _keys;

        internal DbSortExpression(TypeUsage resultType, DbExpressionBinding input, System.Collections.ObjectModel.ReadOnlyCollection sortOrder) 
            : base(DbExpressionKind.Sort, resultType)
        { 
            Debug.Assert(input != null, "DbSortExpression input cannot be null"); 
            Debug.Assert(sortOrder != null, "DbSortExpression sort order cannot be null");
            Debug.Assert(TypeSemantics.IsCollectionType(resultType), "DbSkipExpression requires a collection result type"); 

            this._input = input;
            this._keys = sortOrder;
        } 

        ///  
        /// Gets the  that specifies the input set. 
        /// 
        public DbExpressionBinding Input { get { return _input; } } 

        /// 
        /// Gets a  list that defines the sort order.
        ///  
        public IList SortOrder { get { return _keys; } }
 
        ///  
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        ///  
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    ///  
    /// Represents the set union (without duplicate removal) operation between the left and right operands. 
    /// 
    ///  
    /// DbUnionAllExpression requires that its arguments have a common collection result type
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbUnionAllExpression : DbBinaryExpression 
    {
        internal DbUnionAllExpression(TypeUsage resultType, DbExpression left, DbExpression right) 
            : base(DbExpressionKind.UnionAll, resultType, left, right) 
        {
        } 

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// 
// @owner  [....]
// @backupOwner [....] 
//--------------------------------------------------------------------- 

using System; 
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics;
 
using System.Data.Common;
using System.Data.Metadata.Edm; 
using System.Data.Common.CommandTrees.Internal; 

namespace System.Data.Common.CommandTrees 
{
    /// 
    /// Represents an apply operation, which is the invocation of the specified functor for each element in the specified input set.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbApplyExpression : DbExpression 
    { 
        private readonly DbExpressionBinding _input;
        private readonly DbExpressionBinding _apply; 

        internal DbApplyExpression(DbExpressionKind applyKind, TypeUsage resultRowCollectionTypeUsage, DbExpressionBinding input, DbExpressionBinding apply)
            : base(applyKind, resultRowCollectionTypeUsage)
        { 
            Debug.Assert(input != null, "DbApplyExpression input cannot be null");
            Debug.Assert(input != null, "DbApplyExpression apply cannot be null"); 
            Debug.Assert(DbExpressionKind.CrossApply == applyKind || DbExpressionKind.OuterApply == applyKind, "Invalid DbExpressionKind for DbApplyExpression"); 

            _input = input; 
            _apply = apply;
        }

        ///  
        /// Gets the  that specifies the functor that is invoked for each element in the input set.
        ///  
        public DbExpressionBinding Apply { get { return _apply;  } } 

        ///  
        /// Gets the  that specifies the input set.
        /// 
        public DbExpressionBinding Input { get { return _input; } }
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }

        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    }

    ///  
    /// Represents the removal of duplicate elements from the specified set operand.
    ///  
    ///  
    /// DbDistinctExpression requires that its argument has a collection result type
    /// with an element type that is equality comparable. 
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbDistinctExpression : DbUnaryExpression
    { 
        internal DbDistinctExpression(TypeUsage resultType, DbExpression argument)
            : base(DbExpressionKind.Distinct, resultType, argument) 
        { 
            Debug.Assert(TypeSemantics.IsCollectionType(argument.ResultType), "DbDistinctExpression argument must have a collection result type");
        } 

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
 
    /// 
    /// Represents the conversion of the specified set operand to a singleton.
    /// 
    ///  
    /// DbElementExpression requires that its argument has a collection result type
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbElementExpression : DbUnaryExpression
    { 
        private bool _singlePropertyUnwrapped;

        internal DbElementExpression(TypeUsage resultType, DbExpression argument)
            : base(DbExpressionKind.Element, resultType, argument) 
        {
            this._singlePropertyUnwrapped = false; 
        } 

        internal DbElementExpression(TypeUsage resultType, DbExpression argument, bool unwrapSingleProperty) 
            : base(DbExpressionKind.Element, resultType, argument)
        {
            this._singlePropertyUnwrapped = unwrapSingleProperty;
        } 

        ///  
        /// Is the result type of the element equal to the result type of the single property 
        /// of the element of its operand?
        ///  
        internal bool IsSinglePropertyUnwrapped { get { return _singlePropertyUnwrapped; } }

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        /// 
        /// An instance of DbExpressionVisitor. 
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by 
        ///  is null 
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    /// 
    /// Represents the set subtraction operation between the left and right operands.
    ///  
    /// 
    /// DbExceptExpression requires that its arguments have a common collection result type 
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbExceptExpression : DbBinaryExpression 
    {
        internal DbExceptExpression(TypeUsage resultType, DbExpression left, DbExpression right)
            : base(DbExpressionKind.Except, resultType, left, right)
        { 
            Debug.Assert(object.ReferenceEquals(resultType, left.ResultType), "DbExceptExpression result type should be result type of left argument");
        } 
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        /// 
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by 
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
 
    ///  
    /// Represents a predicate applied to an input set to produce the set of elements that satisfy the predicate.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbFilterExpression : DbExpression
    {
        private readonly DbExpressionBinding _input; 
        private readonly DbExpression _predicate;
 
        internal DbFilterExpression(TypeUsage resultType, DbExpressionBinding input, DbExpression predicate) 
            : base(DbExpressionKind.Filter, resultType)
        { 
            Debug.Assert(input != null, "DbFilterExpression input cannot be null");
            Debug.Assert(predicate != null, "DbBFilterExpression predicate cannot be null");
            Debug.Assert(TypeSemantics.IsPrimitiveType(predicate.ResultType, PrimitiveTypeKind.Boolean), "DbFilterExpression predicate must have a Boolean result type");
 
            _input = input;
            _predicate = predicate; 
        } 

        ///  
        /// Gets the  that specifies the input set.
        /// 
        public DbExpressionBinding Input { get { return _input; } }
 
        /// 
        /// Gets the  that specifies the predicate used to filter the input set. 
        ///  
        public DbExpression Predicate { get { return _predicate; } }
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value.
        /// 
        /// An instance of DbExpressionVisitor. 
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by 
        ///  is null 
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    } 

    ///  
    /// Represents a group by operation, which is a grouping of the elements in the input set based on the specified key expressions followed by the application of the specified aggregates.
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbGroupByExpression : DbExpression 
    {
        private readonly DbGroupExpressionBinding _input; 
        private readonly DbExpressionList _keys; 
        private readonly System.Collections.ObjectModel.ReadOnlyCollection _aggregates;
 
        internal DbGroupByExpression(TypeUsage collectionOfRowResultType,
                                     DbGroupExpressionBinding input,
                                     DbExpressionList groupKeys,
                                     System.Collections.ObjectModel.ReadOnlyCollection aggregates) 
            : base(DbExpressionKind.GroupBy, collectionOfRowResultType)
        { 
            Debug.Assert(input != null, "DbGroupExpression input cannot be null"); 
            Debug.Assert(groupKeys != null, "DbGroupExpression keys cannot be null");
            Debug.Assert(aggregates != null, "DbGroupExpression aggregates cannot be null"); 
            Debug.Assert(groupKeys.Count > 0 || aggregates.Count > 0, "At least one key or aggregate is required");

            _input = input;
            _keys = groupKeys; 
            _aggregates = aggregates;
        } 
 
        /// 
        /// Gets the  that specifies the input set and provides access to the set element and group element variables. 
        /// 
        public DbGroupExpressionBinding Input { get { return _input; } }

        ///  
        /// Gets an  list that provides grouping keys.
        ///  
        public IList Keys { get { return _keys; } } 

        ///  
        /// Gets an  list that provides the aggregates to apply.
        /// 
        public IList Aggregates { get { return _aggregates; } }
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }

        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    }

    ///  
    /// Represents the set intersection operation between the left and right operands.
    ///  
    ///  
    /// DbIntersectExpression requires that its arguments have a common collection result type
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbIntersectExpression : DbBinaryExpression
    {
        internal DbIntersectExpression(TypeUsage resultType, DbExpression left, DbExpression right) 
            : base(DbExpressionKind.Intersect, resultType, left, right)
        { 
        } 

        ///  
        /// The visitor pattern method for expression visitors that do not produce a result value.
        /// 
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        ///  
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by 
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 
 
    /// 
    /// Represents an unconditional join operation between the given collection arguments 
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbCrossJoinExpression : DbExpression
    { 
        private readonly System.Collections.ObjectModel.ReadOnlyCollection _inputs;
 
        internal DbCrossJoinExpression(TypeUsage collectionOfRowResultType, System.Collections.ObjectModel.ReadOnlyCollection inputs) 
            : base(DbExpressionKind.CrossJoin, collectionOfRowResultType)
       { 
           Debug.Assert(inputs != null, "DbCrossJoin inputs cannot be null");
           Debug.Assert(inputs.Count >= 2, "DbCrossJoin requires at least two inputs");

           _inputs = inputs; 
        }
 
        ///  
        /// Gets an  list that provide the input sets to the join.
        ///  
        public IList Inputs { get { return _inputs; } }

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        /// 
        /// An instance of DbExpressionVisitor. 
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by 
        ///  is null 
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    /// 
    /// Represents an inner, left outer or full outer join operation between the given collection arguments on the specified join condition.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbJoinExpression : DbExpression 
    { 
        private readonly DbExpressionBinding _left;
        private readonly DbExpressionBinding _right; 
        private readonly DbExpression _condition;

        internal DbJoinExpression(DbExpressionKind joinKind, TypeUsage collectionOfRowResultType, DbExpressionBinding left, DbExpressionBinding right, DbExpression condition)
            : base(joinKind, collectionOfRowResultType) 
        {
            Debug.Assert(left != null, "DbJoinExpression left cannot be null"); 
            Debug.Assert(right != null, "DbJoinExpression right cannot be null"); 
            Debug.Assert(condition != null, "DbJoinExpression condition cannot be null");
            Debug.Assert(DbExpressionKind.InnerJoin == joinKind || 
                         DbExpressionKind.LeftOuterJoin == joinKind ||
                         DbExpressionKind.FullOuterJoin == joinKind,
                         "Invalid DbExpressionKind specified for DbJoinExpression");
 
            _left = left;
            _right = right; 
            _condition = condition; 
        }
 
        /// 
        /// Gets the  provides the left input.
        /// 
        public DbExpressionBinding Left { get { return _left; } } 

        ///  
        /// Gets the  provides the right input. 
        /// 
        public DbExpressionBinding Right { get { return _right; } } 

        /// 
        /// Gets the  that defines the join condition to apply.
        ///  
        public DbExpression JoinCondition { get { return _condition; } }
 
        ///  
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        ///  
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    ///  
    /// Represents the restriction of the number of elements in the Argument collection to the specified Limit value. 
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbLimitExpression : DbExpression
    {
        private readonly DbExpression _argument;
        private readonly DbExpression _limit; 
        private readonly bool _withTies;
 
        internal DbLimitExpression(TypeUsage resultType, DbExpression argument, DbExpression limit, bool withTies) 
            : base(DbExpressionKind.Limit, resultType)
        { 
            Debug.Assert(argument != null, "DbLimitExpression argument cannot be null");
            Debug.Assert(limit != null, "DbLimitExpression limit cannot be null");
            Debug.Assert(object.ReferenceEquals(resultType, argument.ResultType), "DbLimitExpression result type must be the result type of the argument");
 
            this._argument = argument;
            this._limit = limit; 
            this._withTies = withTies; 
        }
 
        /// 
        /// Gets the expression that specifies the input collection.
        /// 
        public DbExpression Argument { get { return this._argument; } } 

        ///  
        /// Gets the expression that specifies the limit on the number of elements returned from the input collection. 
        /// 
        public DbExpression Limit { get { return this._limit; } } 

        /// 
        /// Gets whether the limit operation will include tied results, which could produce more results than specifed by the Limit value if ties are present.
        ///  
        public bool WithTies { get { return _withTies; } }
 
        ///  
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        ///  
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    ///  
    /// Represents the projection of a given set of values over the specified input set. 
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbProjectExpression : DbExpression
    {
        private readonly DbExpressionBinding _input;
        private readonly DbExpression _projection; 

        internal DbProjectExpression(TypeUsage resultType, DbExpressionBinding input, DbExpression projection) 
            : base(DbExpressionKind.Project, resultType) 
        {
            Debug.Assert(input != null, "DbProjectExpression input cannot be null"); 
            Debug.Assert(projection != null, "DbProjectExpression projection cannot be null");

            this._input = input;
            this._projection = projection; 
        }
 
        ///  
        /// Gets the  that specifies the input set.
        ///  
        public DbExpressionBinding Input { get { return _input; } }

        /// 
        /// Gets the  that defines the projection. 
        /// 
        public DbExpression Projection { get { return _projection; } } 
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        /// 
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by 
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
 
    ///  
    /// Represents a quantifier operation of the specified kind (Any, All) over the elements of the specified input set.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbQuantifierExpression : DbExpression
    {
        private readonly DbExpressionBinding _input; 
        private readonly DbExpression _predicate;
 
        internal DbQuantifierExpression(DbExpressionKind kind, TypeUsage booleanResultType, DbExpressionBinding input, DbExpression predicate) 
            : base(kind, booleanResultType)
        { 
            Debug.Assert(input != null, "DbQuantifierExpression input cannot be null");
            Debug.Assert(predicate != null, "DbQuantifierExpression predicate cannot be null");
            Debug.Assert(TypeSemantics.IsPrimitiveType(booleanResultType, PrimitiveTypeKind.Boolean), "DbQuantifierExpression must have a Boolean result type");
            Debug.Assert(TypeSemantics.IsPrimitiveType(predicate.ResultType, PrimitiveTypeKind.Boolean), "DbQuantifierExpression predicate must have a Boolean result type"); 

            this._input = input; 
            this._predicate = predicate; 
        }
 
        /// 
        /// Gets the  that specifies the input set.
        /// 
        public DbExpressionBinding Input { get { return _input; } } 

        ///  
        /// Gets the Boolean predicate that should be evaluated for each element in the input set. 
        /// 
        public DbExpression Predicate { get { return _predicate; } } 

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
 
    /// 
    /// Specifies a sort key that can be used as part of the sort order in a DbSortExpression.
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbSortClause
    { 
        private readonly DbExpression _expr; 
        private readonly bool _asc;
        private readonly string _coll; 

        internal DbSortClause(DbExpression key, bool asc, string collation)
        {
            Debug.Assert(key != null, "DbSortClause key cannot be null"); 

            _expr = key; 
            _asc = asc; 
            _coll = collation;
        } 

        /// 
        /// Gets a Boolean value indicating whether or not this sort key is sorted ascending.
        ///  
        public bool Ascending { get { return _asc; } }
 
        ///  
        /// Gets a string value that specifies the collation for this sort key.
        ///  
        public string Collation { get { return _coll; } }

        /// 
        /// Gets the  that provides the value for this sort key. 
        /// 
        public DbExpression Expression { get { return _expr; } } 
    } 

    ///  
    /// Represents a skip operation of the specified number of elements of the input set after the ordering described in the given sort keys is applied.
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbSkipExpression : DbExpression 
    {
        private readonly DbExpressionBinding _input; 
        private readonly System.Collections.ObjectModel.ReadOnlyCollection _keys; 
        private readonly DbExpression _count;
 
        internal DbSkipExpression(TypeUsage resultType, DbExpressionBinding input, System.Collections.ObjectModel.ReadOnlyCollection sortOrder, DbExpression count)
            : base(DbExpressionKind.Skip, resultType)
        {
            Debug.Assert(input != null, "DbSkipExpression input cannot be null"); 
            Debug.Assert(sortOrder != null, "DbSkipExpression sort order cannot be null");
            Debug.Assert(count != null, "DbSkipExpression count cannot be null"); 
            Debug.Assert(TypeSemantics.IsCollectionType(resultType), "DbSkipExpression requires a collection result type"); 

            this._input = input; 
            this._keys = sortOrder;
            this._count = count;
        }
 
        /// 
        /// Gets the  that specifies the input set. 
        ///  
        public DbExpressionBinding Input { get { return _input; } }
 
        /// 
        /// Gets a  list that defines the sort order.
        /// 
        public IList SortOrder { get { return _keys; } } 

        ///  
        /// Gets the expression that specifies the number of elements from the input collection to skip. 
        /// 
        public DbExpression Count 
        {
            get { return _count; }
        }
 
        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value. 
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }

        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType. 
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    }

    ///  
    /// Represents a sort operation applied to the elements of the specified input set based on the given sort keys.
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
    public sealed class DbSortExpression : DbExpression
    { 
        private readonly DbExpressionBinding _input;
        private readonly System.Collections.ObjectModel.ReadOnlyCollection _keys;

        internal DbSortExpression(TypeUsage resultType, DbExpressionBinding input, System.Collections.ObjectModel.ReadOnlyCollection sortOrder) 
            : base(DbExpressionKind.Sort, resultType)
        { 
            Debug.Assert(input != null, "DbSortExpression input cannot be null"); 
            Debug.Assert(sortOrder != null, "DbSortExpression sort order cannot be null");
            Debug.Assert(TypeSemantics.IsCollectionType(resultType), "DbSkipExpression requires a collection result type"); 

            this._input = input;
            this._keys = sortOrder;
        } 

        ///  
        /// Gets the  that specifies the input set. 
        /// 
        public DbExpressionBinding Input { get { return _input; } } 

        /// 
        /// Gets a  list that defines the sort order.
        ///  
        public IList SortOrder { get { return _keys; } }
 
        ///  
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
 
        /// 
        /// The visitor pattern method for expression visitors that produce a result value of a specific type. 
        ///  
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of .
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } }
    } 

    ///  
    /// Represents the set union (without duplicate removal) operation between the left and right operands. 
    /// 
    ///  
    /// DbUnionAllExpression requires that its arguments have a common collection result type
    /// 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    public sealed class DbUnionAllExpression : DbBinaryExpression 
    {
        internal DbUnionAllExpression(TypeUsage resultType, DbExpression left, DbExpression right) 
            : base(DbExpressionKind.UnionAll, resultType, left, right) 
        {
        } 

        /// 
        /// The visitor pattern method for expression visitors that do not produce a result value.
        ///  
        /// An instance of DbExpressionVisitor.
        ///  is null 
        public override void Accept(DbExpressionVisitor visitor) { if (visitor != null) { visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 

        ///  
        /// The visitor pattern method for expression visitors that produce a result value of a specific type.
        /// 
        /// An instance of a typed DbExpressionVisitor that produces a result value of type TResultType.
        /// The type of the result produced by  
        ///  is null
        /// An instance of . 
        public override TResultType Accept(DbExpressionVisitor visitor) { if (visitor != null) { return visitor.Visit(this); } else { throw EntityUtil.ArgumentNull("visitor"); } } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK