Method Filter
- Namespace
- YndigoBlue.Velocity.Engine
- Assembly
- YndigoBlue.Velocity.dll
Filter(string, string)
Filters the result set using a DataTable expression with sorting.
public DataRow[] Filter(string expression, string sort)
Parameters
expressionstringThe filter expression using DataTable expression syntax (e.g., "price > 100 AND category = 'Electronics'").
sortstringThe sort expression (e.g., "price DESC, name ASC").
Returns
- DataRow[]
An array of DataRow objects matching the filter criteria, sorted as specified.
Examples
var conn = new MySqlDatasourceConnection
{
Hostname = "localhost",
Database = "inventory",
Username = "root",
Password = "password"
};
using (var manager = new Manager(conn))
{
var schema = manager.LoadSchema("inventory");
var productsTable = schema["products"];
var query = new Query()
.Select([productsTable["id"], productsTable["name"], productsTable["price"], productsTable["stock"]])
.From(productsTable);
ResultSet results = manager.ExecuteResultSet(query);
// Filter for low stock items, sorted by price
DataRow[] lowStock = results.Filter("stock < 10", "price DESC");
foreach (DataRow row in lowStock)
{
Console.WriteLine($"{row["name"]}: ${row["price"]} (Stock: {row["stock"]})");
}
results.Dispose();
}
Filter(string)
Filters the result set using a DataTable expression without sorting.
public DataRow[] Filter(string expression)
Parameters
expressionstringThe filter expression using DataTable expression syntax (e.g., "price > 100 AND category = 'Electronics'").
Returns
- DataRow[]
An array of DataRow objects matching the filter criteria.