Table of Contents

Class Statement

Namespace
YndigoBlue.Velocity.Model
Assembly
YndigoBlue.Velocity.dll

Represents a raw SQL statement that can be used as an element in expressions or queries.

public class Statement : IElement
Inheritance
Statement
Implements

Examples

Using a Statement for database-specific function:

// PostgreSQL-specific function
Statement pgFunction = new Statement("NOW() AT TIME ZONE 'UTC'");

Expression expr = new Expression("utc_time", pgFunction);
query.AddSelectItem(expr);

// SQL: SELECT NOW() AT TIME ZONE 'UTC' AS utc_time

Using Statement in a WHERE clause (advanced):

// Database-specific JSONB query (PostgreSQL)
Statement jsonCondition = new Statement("data->>'status' = 'active'");

// Note: This is for illustration - in practice you'd use Filter and Criterion
// when possible for better portability

Embedding raw SQL in expressions:

// MySQL-specific DATE_FORMAT
Statement dateFormat = new Statement("DATE_FORMAT(created_at, '%Y-%m-%d')");

Expression formattedDate = new Expression("formatted_date", dateFormat);
query.AddSelectItem(formattedDate);

// SQL: SELECT DATE_FORMAT(created_at, '%Y-%m-%d') AS formatted_date

Remarks

Statement allows you to embed raw SQL within Velocity's type-safe query building. This is an escape hatch for database-specific features not directly supported by Velocity's abstractions.

WARNING: Using raw SQL statements reduces portability across database systems. Statements are not validated or transformed by Velocity - they are passed directly to the database.

Use Statement sparingly and only when necessary for database-specific functionality. Prefer using Velocity's native query building classes (Query, Expression, Function, etc.) for maximum portability.

Constructors

Statement(string)

Creates a new raw SQL statement.

Properties

Sql

Gets or sets the raw SQL text of this statement.