Class Substring
- Namespace
- YndigoBlue.Velocity.Functions
- Assembly
- YndigoBlue.Velocity.dll
Represents the SUBSTRING function that extracts a portion of a string.
public class Substring : Function, ICheckItem, IDefaultItem, IFilterItem, IElement
- Inheritance
-
Substring
- Implements
Remarks
The SUBSTRING function returns a substring starting at a specified position with a specified length. Position indexing varies by database (0-based or 1-based). This function is useful for parsing fixed-width fields, extracting codes, or truncating text.
Examples
Extract a three-character area code from the start of a phone number:
var schema = manager.LoadSchema("crm");
var contacts = schema["contacts"];
var query = new Query()
.Select([ contacts["id"], new Expression("area_code", new Substring(contacts["phone"], 1, 3)) ])
.From(contacts);
var results = manager.Retrieve(query);
Constructors
- Substring(string, int, int)
Initializes a new instance of SUBSTRING for a literal string value with literal parameters.
- Substring(Column, int, int)
Initializes a new instance of SUBSTRING with literal start position and length.
- Substring(Column, int, Column)
Initializes a new instance of SUBSTRING with literal start position and column-based length.
- Substring(Column, Column, int)
Initializes a new instance of SUBSTRING with column-based start position and literal length.
- Substring(Column, Column, Column)
Initializes a new instance of SUBSTRING with column-based start position and length.
- Substring(Expression, int, int)
Initializes a new instance of SUBSTRING for a string expression with literal parameters.