Constant Expressions

 

A constant expression consists of a constant value. Constant values are directly converted to constant command tree expressions, without any translation on the client. This includes expressions that result in a constant value. Therefore, data source behavior should be expected for all expressions involving constants. This can result in behavior that differs from CLR behavior.

The following example shows a constant expression that is evaluated on the server.

[!CODE [DP L2E Conceptual Examples#ConstantExpression](../CodeSnippet/VS_Snippets_Data/DP L2E Conceptual Examples#constantexpression)]

LINQ to Entities does not support using a user class as a constant. However, a property reference on a user class is considered a constant, and will be converted to a command tree constant expression and executed on the data source.

Expressions in LINQ to Entities Queries

Show: