Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Expression.Invoke Method (Expression, IEnumerable(Expression))

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

Namespace:  System.Linq.Expressions
Assembly:  System.Core (in System.Core.dll)
static member Invoke : 
        expression:Expression * 
        arguments:IEnumerable<Expression> -> InvocationExpression

Parameters

expression
Type: System.Linq.Expressions.Expression

An Expression that represents the delegate or lambda expression to be applied to.

arguments
Type: System.Collections.Generic.IEnumerable(Expression)

An IEnumerable(T) that contains Expression objects that represent the arguments that the delegate or lambda expression is applied to.

Return Value

Type: System.Linq.Expressions.InvocationExpression
An InvocationExpression that applies the specified delegate or lambda expression to the provided arguments.
ExceptionCondition
ArgumentNullException

expression is a null reference (Nothing in Visual Basic).

ArgumentException

expression.Type does not represent a delegate type or an Expression(TDelegate).

-or-

The Type property of an element of arguments is not assignable to the type of the corresponding parameter of the delegate represented by expression.

InvalidOperationException

arguments does not contain the same number of elements as the list of parameters for the delegate represented by expression.

The Type property of the resulting InvocationExpression represents the return type of the delegate that is represented by expression.Type.

The Arguments property of the resulting InvocationExpression is empty if arguments is a null reference (Nothing in Visual Basic). Otherwise, it contains the same elements as arguments except that some of these Expression objects may be quoted.

NoteNote

An element will be quoted only if the corresponding parameter of the delegate represented by expression is of type Expression. Quoting means the element is wrapped in a Quote node. The resulting node is a UnaryExpression whose Operand property is the element of arguments.

The following example demonstrates how to use the Invoke(Expression, Expression[]) method to create an InvocationExpression that represents the invocation of a lambda expression with specified arguments.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.