Constants Expression

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, a 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.

using ( FluentModel dbContext = new FluentModel() )
{
   IQueryable<int> products = from product in dbContext.Products
                              where product.UnitPrice > 20 + 3
                              select product.ProductID;
   foreach ( int id in products )
   {
       Console.WriteLine( id );
   }
}
Using dbContext As New FluentModel()
 Dim products As IQueryable(Of Integer) = From product In dbContext.Products
                                          Where product.UnitPrice > 20 + 3
                                          Select product.ProductID
 For Each id As Integer In products
  Console.WriteLine(id)
 Next id
End Using

See Also