Class Selection
- Namespace
- YndigoBlue.Velocity.Model
- Assembly
- YndigoBlue.Velocity.dll
Represents a simple SELECT item in a query result - typically a column or expression alias.
public class Selection : ISelectItem, IElement
- Inheritance
-
Selection
- Implements
Examples
Selections are created internally when retrieving query results:
Query query = new Query();
query.AddFromItem(usersTable);
query.AddSelectItem(usersTable["username"]);
Expression totalExpression = new Expression("order_total");
totalExpression.Add(ordersTable["quantity"]);
totalExpression.Add(new ArithmeticOperator(ArithmeticType.Multiply));
totalExpression.Add(ordersTable["price"]);
query.AddSelectItem(totalExpression);
// When this query executes, the result contains Selections:
// - Selection("username", DataType.VarChar)
// - Selection("order_total", DataType.Decimal)
IEnumerable<Result> results = manager.Retrieve(query);
foreach (Result result in results)
{
// Access fields by the selection names
string username = result.GetFieldString("username");
decimal orderTotal = result.GetFieldDecimal("order_total");
}
Remarks
Selection is the simplest implementation of ISelectItem, representing what is actually returned from a query rather than the source columns or expressions used to generate the result.
Selections are typically created internally by Velocity when processing query results. They capture the name and data type of each field in the result set.
Unlike Column which represents a table column definition, Selection only represents the output field from a query - which may be a column, an aliased expression, or a function result.
Constructors
- Selection(string, DataType)
Creates a new selection with the specified name and data type.
Fields
Properties
- DataType
Gets the data type of this selection.
- Name
Gets the name of this selection (the field name in the result set).
- Precision
Gets the precision of this selection (for numeric types). Always returns 0 for Selection.
- Scale
Gets the scale of this selection (for decimal types). Always returns 0 for Selection.
- Size
Gets or sets the size of this selection (for character types).