Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Common / CommandTrees / AbstractExpressions.cs / 1305376 / AbstractExpressions.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.ComponentModel; using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.Data.Metadata.Edm; using System.Data.Common.CommandTrees.Internal; namespace System.Data.Common.CommandTrees { ////// Describes the different "kinds" (classes) of expressions /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] public enum DbExpressionKind { ////// True for all. /// All = 0, ////// Logical And. /// And = 1, ////// True for any. /// Any = 2, ////// Conditional case statement. /// Case = 3, ////// Polymorphic type cast. /// Cast = 4, ////// A constant value. /// Constant = 5, ////// Cross apply /// CrossApply = 6, ////// Cross join /// CrossJoin = 7, ////// Dereference. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Deref")] Deref = 8, ////// Duplicate removal. /// Distinct = 9, ////// Division. /// Divide = 10, ////// Set to singleton conversion. /// Element = 11, ////// Entity ref value retrieval. /// EntityRef = 12, ////// Equality /// Equals = 13, ////// Set subtraction /// Except = 14, ////// Restriction. /// Filter = 15, ////// Full outer join /// FullOuterJoin = 16, ////// Invocation of a stand-alone function /// Function = 17, ////// Greater than. /// GreaterThan = 18, ////// Greater than or equal. /// GreaterThanOrEquals = 19, ////// Grouping. /// GroupBy = 20, ////// Inner join /// InnerJoin = 21, ////// Set intersection. /// Intersect = 22, ////// Empty set determination. /// IsEmpty = 23, ////// Null determination. /// IsNull = 24, ////// Type comparison (specified Type or Subtype). /// IsOf = 25, ////// Type comparison (specified Type only). /// IsOfOnly = 26, ////// Application of a lambda function /// Lambda = 57, ////// Left outer join /// LeftOuterJoin = 27, ////// Less than. /// LessThan = 28, ////// Less than or equal. /// LessThanOrEquals = 29, ////// String comparison. /// Like = 30, ////// Result count restriction (TOP n). /// Limit = 31, #if METHOD_EXPRESSION ////// Invocation of a static or instance method. /// Method, #endif ////// Subtraction. /// Minus = 32, ////// Modulo. /// Modulo = 33, ////// Multiplication. /// Multiply = 34, ////// Instance, row, and set construction. /// NewInstance = 35, ////// Logical Not. /// Not = 36, ////// Inequality. /// NotEquals = 37, ////// Null. /// Null = 38, ////// Set members by type (or subtype). /// OfType = 39, ////// Set members by (exact) type. /// OfTypeOnly = 40, ////// Logical Or. /// Or = 41, ////// Outer apply. /// OuterApply = 42, ////// A reference to a parameter. /// ParameterReference = 43, ////// Addition. /// Plus = 44, ////// Projection. /// Project = 45, ////// Retrieval of a static or instance property. /// Property = 46, ////// Reference. /// Ref = 47, ////// Ref key value retrieval. /// RefKey = 48, ////// Navigation of a (composition or association) relationship. /// RelationshipNavigation = 49, ////// Entity or relationship set scan. /// Scan = 50, ////// Skip elements of an ordered collection. /// Skip = 51, ////// Sorting. /// Sort = 52, ////// Type conversion. /// Treat = 53, ////// Negation. /// UnaryMinus = 54, ////// Set union (with duplicates). /// UnionAll = 55, ////// A reference to a variable. /// VariableReference = 56 } ////// The base type for all expressions /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] public abstract class DbExpression { private readonly TypeUsage _type; private readonly DbExpressionKind _kind; private static int s_instanceCount; // Bid counter internal readonly int ObjectId = System.Threading.Interlocked.Increment(ref s_instanceCount); internal DbExpression(DbExpressionKind kind, TypeUsage type) { CheckExpressionKind(kind); _kind = kind; Debug.Assert(type != null, string.Format(CultureInfo.InvariantCulture, "{0}.Type is null in DbExpression constructor", this.GetType().Name)); if (!TypeSemantics.IsNullable(type)) { type = type.ShallowCopy(new FacetValues { Nullable = true }); } Debug.Assert(type.IsReadOnly, "Editable type metadata specified for DbExpression.Type"); this._type = type; } ////// Gets the type metadata for the result type of the expression. /// public TypeUsage ResultType { get { return _type; } } ////// Gets the kind of the expression, which indicates the operation of this expression. /// public DbExpressionKind ExpressionKind { get { return _kind; } } ////// The visitor pattern interface method for expression visitors that do not produce a result value. /// /// An instance of DbExpressionVisitor. ///public abstract void Accept(DbExpressionVisitor visitor); /// is null /// The visitor pattern interface 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 abstract TResultType Accept. (DbExpressionVisitor visitor); #region Equals / GetHashCode // Dev10#547254: Easy to confuse DbExpressionBuilder.Equal with object.Equals method // The object.Equals method is overriden on DbExpression and marked so that it does // not appear in IntelliSense to avoid confusion with the DbExpressionBuilder.Equal // expression construction method. Overriding Equals also requires that GetHashCode // is overridden, however in both cases we defer to the System.Object implementation. [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { return base.Equals(obj); } public override int GetHashCode() { return base.GetHashCode(); } #endregion #if PUBLIC_DBEXPRESSIONBUILDER #region Implicit Cast Operators /// /// Creates a /// The binary value on which the returned expression should be based ///that represents the specified binary value, which may be null ///A public static DbExpression FromBinary(byte[] value) { if (null == value) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Binary); } return ExpressionBuilder.DbExpressionBuilder.Constant(value); } public static implicit operator DbExpression(byte[] value) { return DbExpression.FromBinary(value); } ///that represents the specified binary value /// Creates a /// The Boolean value on which the returned expression should be based ///that represents the specified (nullable) Boolean value /// A public static DbExpression FromBoolean(bool? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Boolean); } return (value.Value ? ExpressionBuilder.DbExpressionBuilder.True : ExpressionBuilder.DbExpressionBuilder.False); } public static implicit operator DbExpression(bool? value) { return DbExpression.FromBoolean(value); } ///that represents the specified Boolean value /// Creates a /// The byte value on which the returned expression should be based ///that represents the specified (nullable) byte value /// A public static DbExpression FromByte(byte? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Byte); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(byte? value) { return DbExpression.FromByte(value); } ///that represents the specified byte value /// Creates a /// The DateTime value on which the returned expression should be based ///that represents the specified (nullable) value /// A public static DbExpression FromDateTime(DateTime? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.DateTime); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(DateTime? value) { return DbExpression.FromDateTime(value); } ///that represents the specified DateTime value /// Creates a /// The DateTimeOffset value on which the returned expression should be based ///that represents the specified (nullable) value /// A public static DbExpression FromDateTimeOffset(DateTimeOffset? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.DateTimeOffset); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(DateTimeOffset? value) { return DbExpression.FromDateTimeOffset(value); } ///that represents the specified DateTimeOffset value /// Creates a /// The decimal value on which the returned expression should be based ///that represents the specified (nullable) decimal value /// A public static DbExpression FromDecimal(decimal? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Decimal); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(decimal? value) { return DbExpression.FromDecimal(value); } ///that represents the specified decimal value /// Creates a /// The double value on which the returned expression should be based ///that represents the specified (nullable) double value /// A public static DbExpression FromDouble(double? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Double); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(double? value) { return DbExpression.FromDouble(value); } ///that represents the specified double value /// Creates a /// The Guid value on which the returned expression should be based ///that represents the specified (nullable) value /// A public static DbExpression FromGuid(Guid? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Guid); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(Guid? value) { return DbExpression.FromGuid(value); } ///that represents the specified Guid value /// Creates a /// The Int16 value on which the returned expression should be based ///that represents the specified (nullable) Int16 value /// A public static DbExpression FromInt16(short? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Int16); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(short? value) { return DbExpression.FromInt16(value); } ///that represents the specified Int16 value /// Creates a /// The Int32 value on which the returned expression should be based ///that represents the specified (nullable) Int32 value /// A public static DbExpression FromInt32(int? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Int32); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(int? value) { return DbExpression.FromInt32(value); } ///that represents the specified Int32 value /// Creates a /// The Int64 value on which the returned expression should be based ///that represents the specified (nullable) Int64 value /// A public static DbExpression FromInt64(long? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Int64); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(long? value) { return DbExpression.FromInt64(value); } //// //public static implicit operator DbExpression(sbyte? value) //{ // return DbExpression.FromSByte(value); //} ///that represents the specified Int64 value /// Creates a /// The Single value on which the returned expression should be based ///that represents the specified (nullable) Single value /// A public static DbExpression FromSingle(float? value) { if (!value.HasValue) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.Single); } return ExpressionBuilder.DbExpressionBuilder.Constant(value.Value); } public static implicit operator DbExpression(float? value) { return DbExpression.FromSingle(value); } ///that represents the specified Single value /// Creates a /// The string value on which the returned expression should be based ///that represents the specified string value /// A public static DbExpression FromString(string value) { if (null == value) { return ExpressionBuilder.DbExpressionBuilder.CreatePrimitiveNullExpression(PrimitiveTypeKind.String); } return ExpressionBuilder.DbExpressionBuilder.Constant(value); } public static implicit operator DbExpression(string value) { return DbExpression.FromString(value); } // #endregion #endif #region Internal API ///that represents the specified string value /// Produces a text-based tree representation of the DbExpression tree rooted at this expression /// ///A string containing the text-based tree representation [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal string Print() { return new ExpressionPrinter().Print(this); } internal static void CheckExpressionKind(DbExpressionKind kind) { // Add new valid DbExpressionKind values to this method as well as the enum itself. // DbExpressionKind is a contiguous enum from All = 0 through View if ((kind < DbExpressionKind.All) || (DbExpressionKind.Lambda < kind)) { throw EntityUtil.InvalidEnumerationValue(typeof(DbExpressionKind), (int)kind); } } #endregion } ////// The abstract base type for expressions that accept two expression operands. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] public abstract class DbBinaryExpression : DbExpression { private readonly DbExpression _left; private readonly DbExpression _right; internal DbBinaryExpression(DbExpressionKind kind, TypeUsage type, DbExpression left, DbExpression right) : base(kind, type) { Debug.Assert(left != null, "DbBinaryExpression.Left cannot be null"); Debug.Assert(right != null, "DbBinaryExpression.Right cannot be null"); this._left = left; this._right = right; } ////// Gets the public DbExpression Left { get { return _left; } } ///that defines the left argument. /// /// Gets the public DbExpression Right { get { return _right; } } } ///that defines the right argument. /// /// The abstract base type for expressions that accept a single expression operand /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] public abstract class DbUnaryExpression : DbExpression { private readonly DbExpression _argument; internal DbUnaryExpression(DbExpressionKind kind, TypeUsage resultType, DbExpression argument) : base(kind, resultType) { Debug.Assert(argument != null, "DbUnaryExpression.Argument cannot be null"); this._argument = argument; } ////// Gets the public DbExpression Argument { get { return this._argument; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.that defines the argument. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AttributeCollection.cs
- SoapMessage.cs
- Pair.cs
- SecurityDocument.cs
- UnsafeNativeMethodsPenimc.cs
- DynamicResourceExtension.cs
- OneWayBindingElementImporter.cs
- BitmapEffectGeneralTransform.cs
- Logging.cs
- XmlSchemaComplexContentRestriction.cs
- BinaryMethodMessage.cs
- FacetDescriptionElement.cs
- FormsIdentity.cs
- WebConfigurationHost.cs
- ContentPresenter.cs
- ObjectToIdCache.cs
- ReachPageContentCollectionSerializerAsync.cs
- OperationResponse.cs
- FieldBuilder.cs
- CryptoConfig.cs
- FrameDimension.cs
- GridItemCollection.cs
- PropertyPath.cs
- ScriptingAuthenticationServiceSection.cs
- XmlCodeExporter.cs
- DataGridViewRowsAddedEventArgs.cs
- Column.cs
- DesignerCommandSet.cs
- XmlMessageFormatter.cs
- DbInsertCommandTree.cs
- TreeNodeCollection.cs
- AttributeQuery.cs
- RSAOAEPKeyExchangeDeformatter.cs
- DynamicMethod.cs
- WorkflowTransactionOptions.cs
- InputChannelBinder.cs
- Drawing.cs
- Compiler.cs
- XslException.cs
- QueryContinueDragEvent.cs
- SponsorHelper.cs
- ResourcePermissionBaseEntry.cs
- ArrayList.cs
- IDReferencePropertyAttribute.cs
- BatchParser.cs
- CodeTypeDeclarationCollection.cs
- HWStack.cs
- ISFTagAndGuidCache.cs
- ErrorFormatter.cs
- ConversionValidationRule.cs
- Schema.cs
- HttpWebRequestElement.cs
- RegistryKey.cs
- CasesDictionary.cs
- XsdDateTime.cs
- ScriptRegistrationManager.cs
- FunctionNode.cs
- ReadWriteObjectLock.cs
- Enum.cs
- JsonEncodingStreamWrapper.cs
- XmlSchemaProviderAttribute.cs
- diagnosticsswitches.cs
- ScaleTransform3D.cs
- ServiceXNameTypeConverter.cs
- BitConverter.cs
- ContentPlaceHolder.cs
- ProcessProtocolHandler.cs
- Assembly.cs
- ScrollableControl.cs
- AutomationPatternInfo.cs
- SyndicationDeserializer.cs
- TextModifierScope.cs
- SystemIPInterfaceStatistics.cs
- FunctionNode.cs
- __FastResourceComparer.cs
- SHA256Managed.cs
- LazyTextWriterCreator.cs
- WebPartConnectVerb.cs
- SqlComparer.cs
- XmlSchemaGroup.cs
- ValidatorCollection.cs
- NamedElement.cs
- DataTemplateKey.cs
- ObjectListCommandCollection.cs
- IsolationInterop.cs
- CannotUnloadAppDomainException.cs
- PrintPreviewDialog.cs
- XmlRawWriter.cs
- TypeDescriptor.cs
- GlyphRunDrawing.cs
- FieldAccessException.cs
- DetailsViewInsertEventArgs.cs
- ConnectionInterfaceCollection.cs
- CustomAssemblyResolver.cs
- DesignerTransactionCloseEvent.cs
- PartialToken.cs
- PieceDirectory.cs
- BooleanFacetDescriptionElement.cs
- HttpResponseHeader.cs
- DataGridViewCellParsingEventArgs.cs