Compute Expression

In OQL, operators +, -, *, / can be used to make up of a Compute Expression. For example:

SelectQuery qryProduct = OQL

  .SelectFrom(NW.Product)

  .Where(NW.Product.UnitPrice * NW.Product.UnitsInStock >= 1000);

The SQL statements generated as follows (taking SQL Server as an example)

SELECT [Products].*

FROM [Products]

WHERE

  [Products].[UnitPrice] * [Products].[UnitsInStock] >= 1000

Apart from being used in a Where clause, compute expression can also occur in a Select clause:

SelectQuery qryProduct = OQL

  .Select(NW.Product.UnitPrice * NW.Product.UnitsInStock)

  .From(NW.Product);

The SQL statements generated as follows (taking SQL Server as an example)

SELECT [Products].[UnitPrice] * [Products].[UnitsInStock]

FROM [Products]

 

Related Topics

OQL Expressions