Table of Contents

Class Function

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

Abstract base class for all database function calls in SELECT clauses, expressions, filters, and constraints.

public abstract class Function : ICheckItem, IDefaultItem, IFilterItem, IElement
Inheritance
Function
Implements
Derived

Remarks

Functions encapsulate database-specific function calls in a database-agnostic way. Velocity translates each FunctionType to the correct syntax for the connected database system.

Do not instantiate this class directly. Use the concrete subclasses in the YndigoBlue.Velocity.Functions namespace (e.g. Count, Sum, Upper, Now). These provide strongly-typed constructors and are the preferred API.

Functions that require a composed expression inside the aggregate call — such as SUM(price * quantity) — or the statistical aggregates StdDev and Variance, should use Aggregate instead.

Examples

Aggregate functions in a grouped SELECT:

var schema = manager.LoadSchema("sales");
var orders = schema["orders"];

var query = new Query()
    .Select([
        orders["customer_id"],
        new Expression("order_count", new Count(orders["id"])),
        new Expression("total_spent", new Sum(orders["total"]))
    ])
    .From(orders)
    .GroupBy(orders["customer_id"]);

var results = manager.Retrieve(query);

Scalar string and date functions:

var schema = manager.LoadSchema("hr");
var employees = schema["employees"];

var query = new Query()
    .Select([
        new Expression("full_name", new Concat([ employees["first_name"], new Literal<string>(" "), employees["last_name"] ])),
        new Expression("hire_year", new Year(employees["hire_date"]))
    ])
    .From(employees);

var results = manager.Retrieve(query);

Constructors

Function(FunctionType)

Initializes a new instance of the function with no arguments.

Function(FunctionType, IEnumerable<IElement>)

Initializes a new instance of the function with a collection of element arguments.

Function(FunctionType, IElement)

Initializes a new instance of the function with a single element argument.

Function(FunctionType, params IElement[])

Initializes a new instance of the function with multiple element arguments. For internal use by derived classes only.

Properties

CheckConstraintType

Gets the type of check constraint element.

DefaultConstraintType

Gets the type of default constraint element.

Elements

Gets the list of elements that serve as arguments to this function.

FilterItemType

Gets the type of filter item.

FunctionType

Gets the type of function, used by database adaptors to generate the appropriate SQL.

Methods

IsEqual(ICheckItem)

Determines whether this check item is equal to another check item.

IsEqual(IDefaultItem)

Determines whether this default item is equal to another default item.

ToString()

Returns a string that represents the current object.