Class Left
- Namespace
- YndigoBlue.Velocity.Functions
- Assembly
- YndigoBlue.Velocity.dll
Represents the LEFT string function that returns a specified number of characters from the start of a string.
public class Left : Function, ICheckItem, IDefaultItem, IFilterItem, IElement
- Inheritance
-
Left
- Implements
Remarks
The LEFT function extracts the leftmost characters from a string. This is useful for extracting prefixes, codes, or truncating text to a maximum length. If the length exceeds the string length, the entire string is returned.
Examples
Extract the first three characters of a product code as the category prefix:
var schema = manager.LoadSchema("catalog");
var products = schema["products"];
var query = new Query()
.Select([ products["id"], new Expression("category_prefix", new Left(products["code"], 3)) ])
.From(products);
var results = manager.Retrieve(query);
Constructors
- Left(Column, int)
Initializes a new instance of LEFT with a literal length.
- Left(Column, Column)
Initializes a new instance of LEFT with a column-based length.
- Left(Expression, int)
Initializes a new instance of LEFT for a string expression.