Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
ParameterExpression Class

Updated: October 2008

Represents a named parameter expression.

Namespace:  System.Linq.Expressions
Assembly:  System.Core (in System.Core.dll)
Visual Basic (Declaration)
Public NotInheritable Class ParameterExpression _
    Inherits Expression
Visual Basic (Usage)
Dim instance As ParameterExpression
C#
public sealed class ParameterExpression : Expression
Visual C++
public ref class ParameterExpression sealed : public Expression
JScript
public final class ParameterExpression extends Expression

Use the Parameter factory method to create a ParameterExpression.

The value of the NodeType property of a ParameterExpression object is Parameter.

For example, assume that you have the following query:

Visual Basic
companies.Where(Function(company) company.ToLower() = "coho winery" _
    OrElse company.Length > 16).OrderBy(Function(company) company)
C#
companies.Where(company => (company.ToLower() == "coho winery" || 
    company.Length > 16)).OrderBy(company => company)

In this case, company becomes a parameter expression. To construct an expression tree for this parameter, you can use the following code:

Visual Basic
Dim pe As ParameterExpression = Expression.Parameter(GetType(String), "company")
C#
ParameterExpression pe = Expression.Parameter(typeof(string), "company");

You can find a complete example of using parameter expressions in expression trees in How to: Use Expression Trees to Build Dynamic Queries.

System..::.Object
  System.Linq.Expressions..::.Expression
    System.Linq.Expressions..::.ParameterExpression
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5

Date

History

Reason

October 2008

Added example.

Customer feedback.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker