Table of Contents

Class Length

Namespace
YndigoBlue.Velocity.Functions
Assembly
YndigoBlue.Velocity.dll

Represents the LENGTH string function that returns the number of characters in a string.

public class Length : Function, ICheckItem, IDefaultItem, IFilterItem, IElement
Inheritance
Length
Implements

Remarks

The LENGTH function counts the number of characters in a string value, excluding trailing spaces in some database systems. This function is useful for validation, truncation detection, and data quality checks.

Examples

Retrieve the character length of each product description:

var schema = manager.LoadSchema("catalog");
var products = schema["products"];

var query = new Query()
    .Select([ products["name"], new Expression("desc_length", new Length(products["description"])) ])
    .From(products);

var results = manager.Retrieve(query);

Use the typed Column constructor when working with a pre-resolved column variable:

var schema = manager.LoadSchema("catalog");
var products = schema["products"];
Column descColumn = products["description"];

var query = new Query()
    .Select([ products["id"], new Expression("desc_length", new Length(descColumn)) ])
    .From(products);

var results = manager.Retrieve(query);

Compute the length of a hard-coded string literal directly:

var query = new Query()
    .Select([ new Expression("hello_length", new Length("Hello, World!")) ]);

var results = manager.Retrieve(query);

Constructors

Length(IEnumerable<IElement>)

Initializes a new instance of LENGTH for multiple elements.

Length(string)

Initializes a new instance of LENGTH for a string literal value.

Length(IElement)

Initializes a new instance of LENGTH for a single element.

Length(Column)

Initializes a new instance of LENGTH for a column.