Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

System.Linq.Expressions Namespace

 

The System.Linq.Expressions namespace contains classes, interfaces and enumerations that enable language-level code expressions to be represented as objects in the form of expression trees.

ClassDescription
System_CAPS_pubclassBinaryExpression

Represents an expression that has a binary operator.

System_CAPS_pubclassBlockExpression

Represents a block that contains a sequence of expressions where variables can be defined.

System_CAPS_pubclassCatchBlock

Represents a catch statement in a try block.

System_CAPS_pubclassConditionalExpression

Represents an expression that has a conditional operator.

System_CAPS_pubclassConstantExpression

Represents an expression that has a constant value.

System_CAPS_pubclassDebugInfoExpression

Emits or clears a sequence point for debug information. This allows the debugger to highlight the correct source code when debugging.

System_CAPS_pubclassDefaultExpression

Represents the default value of a type or an empty expression.

System_CAPS_pubclassDynamicExpression

Represents a dynamic operation.

System_CAPS_pubclassDynamicExpressionVisitor

Represents a visitor or rewriter for dynamic expression trees.

System_CAPS_pubclassElementInit

Represents an initializer for a single element of an IEnumerable collection.

System_CAPS_pubclassExpression

Provides the base class from which the classes that represent expression tree nodes are derived. It also contains static (Shared in Visual Basic) factory methods to create the various node types. This is an abstract class.

System_CAPS_pubclassExpression<TDelegate>

Represents a strongly typed lambda expression as a data structure in the form of an expression tree. This class cannot be inherited.

System_CAPS_pubclassExpressionVisitor

Represents a visitor or rewriter for expression trees.

System_CAPS_pubclassGotoExpression

Represents an unconditional jump. This includes return statements, break and continue statements, and other jumps.

System_CAPS_pubclassIndexExpression

Represents indexing a property or array.

System_CAPS_pubclassInvocationExpression

Represents an expression that applies a delegate or lambda expression to a list of argument expressions.

System_CAPS_pubclassLabelExpression

Represents a label, which can be put in any Expression context. If it is jumped to, it will get the value provided by the corresponding GotoExpression. Otherwise, it receives the value in DefaultValue. If the Type equals System.Void, no value should be provided.

System_CAPS_pubclassLabelTarget

Used to represent the target of a GotoExpression.

System_CAPS_pubclassLambdaExpression

Describes a lambda expression. This captures a block of code that is similar to a .NET method body.

System_CAPS_pubclassListInitExpression

Represents a constructor call that has a collection initializer.

System_CAPS_pubclassLoopExpression

Represents an infinite loop. It can be exited with "break".

System_CAPS_pubclassMemberAssignment

Represents assignment operation for a field or property of an object.

System_CAPS_pubclassMemberBinding

Provides the base class from which the classes that represent bindings that are used to initialize members of a newly created object derive.

System_CAPS_pubclassMemberExpression

Represents accessing a field or property.

System_CAPS_pubclassMemberInitExpression

Represents calling a constructor and initializing one or more members of the new object.

System_CAPS_pubclassMemberListBinding

Represents initializing the elements of a collection member of a newly created object.

System_CAPS_pubclassMemberMemberBinding

Represents initializing members of a member of a newly created object.

System_CAPS_pubclassMethodCallExpression

Represents a call to either static or an instance method.

System_CAPS_pubclassNewArrayExpression

Represents creating a new array and possibly initializing the elements of the new array.

System_CAPS_pubclassNewExpression

Represents a constructor call.

System_CAPS_pubclassParameterExpression

Represents a named parameter expression.

System_CAPS_pubclassRuntimeVariablesExpression

An expression that provides runtime read/write permission for variables.

System_CAPS_pubclassSwitchCase

Represents one case of a SwitchExpression.

System_CAPS_pubclassSwitchExpression

Represents a control expression that handles multiple selections by passing control to SwitchCase.

System_CAPS_pubclassSymbolDocumentInfo

Stores information necessary to emit debugging symbol information for a source file, in particular the file name and unique language identifier.

System_CAPS_pubclassTryExpression

Represents a try/catch/finally/fault block.

System_CAPS_pubclassTypeBinaryExpression

Represents an operation between an expression and a type.

System_CAPS_pubclassUnaryExpression

Represents an expression that has a unary operator.

InterfaceDescription
System_CAPS_pubinterfaceIArgumentProvider

Provides an internal interface for accessing the arguments of multiple tree nodes (DynamicExpression, ElementInit, MethodCallExpression, InvocationExpression, NewExpression, and InexExpression). You should not use this API. It is only public due to DLL refactoring and exists only for internal performance optimizations.

This enables two optimizations which reduce the size of expression trees. The first enables the tree nodes to hold onto an IList<T> instead of a ReadOnlyCollection. IList<T> saves the cost of allocating the ReadOnlyCollection for each node. The second enables creating specialized subclasses that hold onto a specific number of arguments (for example, Block2, Block3, Block4). Therefore, these nodes avoid allocating both a ReadOnlyCollection and an array for storing their elements, saving 32 bytes per node.

The expression tree nodes continue to expose the original LINQ properties of ReadOnlyCollections. The nodes do this by re-using a field for storing both the array or an element that would normally be stored in the array.

For the array case, the collection is typed to IList<T> instead of ReadOnlyCollection<T>. When the node is initially constructed it is an array. When the compiler accesses the members it uses this interface. Accessing array elements promotes the array to a ReadOnlyCollection.

For the object case we store the first argument in a field typed to object. When the node is initially constructed, the field holds the Expression. The compiler accesses arguments through this interface, and the accessor for the first argument uses Expression.ReturnObject to return the object that handles the Expression or ReadOnlyCollection case. When the user accesses the ReadOnlyCollection, then the object field is updated to hold directly onto the ReadOnlyCollection.

It is important that the Expressions consistently return the same ReadOnlyCollection. Otherwise, the re-writer tree walker will break. It is a breaking change from LINQ v1 to return different ReadOnlyCollections form the same Expression node. Currently users can rely on object identity to tell if the node has changed. Storing the ReadOnlyCollection in an overloaded field both reduces memory usage and maintains compatibility for the public API.

System_CAPS_pubinterfaceIDynamicExpression

Provides an internal interface for accessing the arguments of DynamicExpression tree nodes as well as CallSite and Rewriting functionality. You should not use this API. It is only public due to DLL refactoring and exists only for internal performance optimizations.

EnumerationDescription
System_CAPS_pubenumExpressionType

Describes the node types for the nodes of an expression tree.

System_CAPS_pubenumGotoExpressionKind

Specifies what kind of jump this GotoExpression represents.

System_CAPS_pubenumMemberBindingType

Describes the binding types that are used in MemberInitExpression objects.

The abstract class Expression provides the root of a class hierarchy used to model expression trees.

The classes in this namespace that derive from Expression, for example MemberExpression and ParameterExpression, are used to represent nodes in an expression tree. The Expression class contains static (Shared in Visual Basic) factory methods to create expression tree nodes of the various types.

The enumeration type ExpressionType specifies the unique node types.

Return to top
Show:
© 2016 Microsoft