Method Search
- Namespace
- YndigoBlue.Velocity.Engine
- Assembly
- YndigoBlue.Velocity.dll
Search(Query)
Executes a query and returns a forward-only, connected data reader for iterating through results.
public ResultReader Search(Query query)
Parameters
Returns
- ResultReader
A ResultReader that provides forward-only access to query results while maintaining an open database connection.
Examples
using (var m = new Manager(conn))
{
var schema = m.LoadSchema("app");
var usersTable = schema["users"];
var query = new Query()
.Select([usersTable["name"], usersTable["email"]])
.From(usersTable)
.Where(new Criterion<bool>(usersTable["active"], ConditionalType.Equals, true));
// Use Search for forward-only iteration
using (var reader = m.Search(query))
{
while (reader.Read())
{
Console.WriteLine($"{reader["name"]}: {reader["email"]}");
}
}
}
Remarks
Use Search for large result sets to avoid loading all data into memory. The connection remains open while iterating. Remember to dispose the ResultReader or wrap it in a using statement to close the connection.
Exceptions
- DbException
Thrown when a database error occurs.