Class Manager
- Namespace
- YndigoBlue.Velocity.Engine
- Assembly
- YndigoBlue.Velocity.dll
The main class used to perform operations within Velocity.
public class Manager : IDisposable
- Inheritance
-
Manager
- Implements
Remarks
For all connected operations a Manager object must be tied to a specific DatasourceType. Optionally it can be created through the default constructor to enable disconnected file operations such as reading and writing schema files.
Managers wrapped in using clauses are the main way to interact with Velocity and the class provides a large number of methods that are the key to the Framework. Most uses of Velocity will involve a number of methods being called one after the other, interacting with a specific database connection. Managers allow for a wide variety of operations including DDL (Data Definition Laguage), DML (Data Manipulation Language) and DQL (Data Query Language).
Note
Use of the Manager class is essentially to your use of Velocity, to achieve success with this framework you need to be familiar with its operation.
You should always wrap a Manager in a using clause so that the unmanaged database connection object can be disposed correctly.
Constructors
- Manager()
Creates a disconnected Manager which can be used for file operations if required, such as loading and writing schema files.
- Manager(DatasourceType, string, string)
Creates a connected Manager from a DatasourceType, a connection string and an optional context settings string.
- Manager(IDatasourceConnection)
Creates a connected Manager from an IDatasourceConnection.
Fields
- LogConfigFile
Path to a custom log4net configuration file.
Properties
- ConnectionString
Gets the connection string used to connect to the datasource.
- DatasourceConnection
Gets the datasource connection object that was used to create this manager.
- DatasourceType
Gets the type of datasource (database system) that this manager is connected to.
Methods
- AddRecord(Record)
Inserts a single record into a table and returns the auto-generated identity value.
- AddRecordAsync(Record, CancellationToken)
Asynchronous counterpart to AddRecord(Record).
- AddRecordNoIdentity(Record)
Inserts a single record into a table without returning an identity value (for tables without auto-increment keys).
- AddRecordNoIdentityAsync(Record, CancellationToken)
Asynchronous counterpart to AddRecordNoIdentity(Record).
- AddRecords(Table, IEnumerable<Column>, Query)
Inserts multiple records into a table using the results from a query (INSERT INTO ... SELECT pattern).
- AddRecordsAsync(Table, IEnumerable<Column>, Query, CancellationToken)
Asynchronous counterpart to AddRecords(Table, IEnumerable<Column>, Query).
- BeginTransaction()
Begins a database transaction with the default isolation level.
- BeginTransaction(IsolationLevel)
Begins a database transaction with a specific isolation level.
- BuildDatabase(Database, bool, bool)
Creates or recreates a complete database with multiple schemas, including all tables, views, constraints, and indexes.
- BuildSchema(Schema, bool, bool)
Creates or recreates a complete schema in the database including all tables, views, constraints, and indexes.
- BuildTable(Table, bool, bool)
Creates or recreates a table in the database including all columns, constraints, and indexes.
- CheckExists(string)
Checks whether a schema exists in the database.
- CommitTransaction()
Commits the current database transaction, making all changes permanent.
- CreateColumn(Column)
Adds a new column to an existing table in the database.
- CreateConstraint(Constraint)
Creates a constraint (primary key, foreign key, unique, check, or default) on an existing table.
- CreateFullTextIndex(FullTextIndex, bool)
Creates a full-text index for advanced text search capabilities on text columns.
- CreateIndex(Index, bool)
Creates a standard index on one or more columns of an existing table.
- CreateSchema(Schema, bool)
Creates an empty schema in the database (schema namespace only, no tables).
- CreateSpatialIndex(SpatialIndex, bool)
Creates a spatial index for geospatial queries on geometry or geography columns.
- CreateTable(Table, bool)
Creates a table in the database with all its columns, constraints, and indexes, optionally overwriting if it exists.
- CreateView(View, bool)
Creates a database view based on a query, optionally overwriting if it exists.
- DeleteRecords(Delete)
Deletes one or more records from a table based on specified criteria.
- DeleteRecordsAsync(Delete, CancellationToken)
Asynchronous counterpart to DeleteRecords(Delete).
- Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- Dispose(bool)
Releases the resources used by the Manager.
- DropConstraint(Constraint)
Drops (deletes) a constraint from the database.
- DropFullTextIndex(FullTextIndex)
Drops (deletes) a full-text index from the database.
- DropIndex(Index)
Drops (deletes) an index from the database.
- DropSchema(Schema)
Drops (deletes) a schema and all its objects from the database.
- DropSpatialIndex(SpatialIndex)
Drops (deletes) a spatial index from the database.
- DropTable(Table)
Drops (deletes) a table from the database, removing the table structure and all its data.
- DropView(View)
Drops (deletes) a view from the database.
- EmptyDatabase(Database, bool)
Removes all tables, views, constraints, and indexes from all schemas in the database, leaving empty schemas.
- EmptySchema(Schema, bool)
Removes all tables, views, constraints, and indexes from a schema, leaving an empty schema.
- EmptyTable(Table)
Deletes all records from a table while keeping the table structure intact.
- ExportData(Query, string, ExportConfig)
Exports query results to a CSV file.
- ExportData(Table, string, ExportConfig)
Exports all data from a table to a CSV file.
- ExportData(View, string, ExportConfig)
Exports all data from a view to a CSV file.
- ExportDatabase(Database, ConfigType, string, ExportConfig, bool)
Exports an entire database (multiple schemas) including all schema definitions and table data to files.
- ExportSchema(Schema, ConfigType, string, ExportConfig, bool)
Exports an entire schema including its definition and all table data to files.
- FullTextRetrieve(Table, IEnumerable<Column>, string)
Performs a full-text search on a table and returns all results in a disconnected result set.
- FullTextRetrieveAsync(Table, IEnumerable<Column>, string, CancellationToken)
Asynchronous counterpart to FullTextRetrieve(Table, IEnumerable<Column>, string).
- FullTextSearch(Table, IEnumerable<Column>, string)
Performs a full-text search on a table and returns a forward-only, connected data reader.
- FullTextSearchAsync(Table, IEnumerable<Column>, string, CancellationToken)
Asynchronous counterpart to FullTextSearch(Table, IEnumerable<Column>, string).
- GetDatabaseInfo()
Retrieves metadata information about the connected database system.
- GetScalar(Query)
Executes a query and returns a single scalar value (typically from aggregate functions or single-value queries).
- GetScalarAsync(Query, CancellationToken)
Asynchronous counterpart to GetScalar(Query).
- GetScalarAsync<T>(Query, CancellationToken)
Asynchronous counterpart to GetScalar<T>(Query).
- GetScalar<T>(Query)
Executes a query and returns a single scalar value cast to a specific type.
- GetSqlBuildDatabase(Database, bool, bool)
Generates the SQL script that would be used to build a database without executing it.
- GetSqlBuildSchema(Schema, bool, bool)
Generates the SQL script that would be used to build a schema without executing it.
- ImportData(Table, string, ImportConfig)
Imports data from a CSV file into a database table.
- LoadDatabase()
Loads all schemas from the connected database into a Database object.
- LoadDatabase(IEnumerable<string>)
Loads specific schemas from the connected database into a Database object.
- LoadSchema(string)
Loads a specific schema from the connected database into a Schema object.
- ReadDatabase(Stream, ConfigType)
Reads a database definition from a stream and returns an in-memory Database object containing multiple schemas.
- ReadDatabase(string, ConfigType)
Reads a database definition from a string and returns an in-memory Database object containing multiple schemas.
- ReadDatabaseFromFile(string, ConfigType)
Reads a database definition from a file and returns an in-memory Database object containing multiple schemas.
- ReadSchema(Stream, ConfigType)
Reads a schema definition from a stream and returns an in-memory Schema object.
- ReadSchema(string, ConfigType)
Reads a schema definition from a string and returns an in-memory Schema object.
- ReadSchemaFromFile(string, ConfigType)
Reads a schema definition from a file and returns an in-memory Schema object.
- Retrieve(Query)
Executes a query and returns all results in a disconnected result set loaded into memory.
- RetrieveAsync(Query, CancellationToken)
Asynchronous counterpart to Retrieve(Query). Executes a query and returns all results in a disconnected in-memory ResultSet, loaded via
ExecuteReaderAsync.
- RetrieveAsync<T>(Query, BindingType, CancellationToken)
Asynchronous counterpart to Retrieve<T>(Query, BindingType). Executes the query, binds the results to a list of
T, and disposes the underlying ResultSet automatically.
- Retrieve<T>(Query, BindingType)
Executes the query, binds the results to a list of
T, and disposes the underlying ResultSet automatically. Nousingblock is required by the caller.
- RollbackTransaction()
Rolls back the current database transaction, undoing all changes made since BeginTransaction.
- RunSql(string)
Executes a raw SQL command against the database.
- Search(Query)
Executes a query and returns a forward-only, connected data reader for iterating through results.
- SearchAsync(Query, CancellationToken)
Asynchronous counterpart to Search(Query). Executes a query and returns a forward-only, streaming ResultReader opened with
ExecuteReaderAsync.
- UpdateColumn(Column)
Updates an existing column's properties in the database.
- UpdateFullTextIndex(FullTextIndex)
Triggers a full rebuild of a full-text index, re-indexing all rows in the associated table.
- UpdateRecords(Update)
Updates one or more records in a table based on specified criteria.
- UpdateRecordsAsync(Update, CancellationToken)
Asynchronous counterpart to UpdateRecords(Update).
- UpdateSchema(Schema, bool)
Updates an existing schema to match the provided schema definition by adding, modifying, or removing objects.
- ValidateSchema(Schema)
Validates that a schema definition matches the actual schema structure in the database.
- WriteDatabase(Database, Stream, ConfigType, bool)
Writes a database definition (with multiple schemas) to a stream in the specified format.
- WriteDatabase(Database, string, ConfigType, bool)
Writes a database definition (with multiple schemas) to a file in the specified format.
- WriteSchema(Schema, Stream, ConfigType, bool)
Writes a schema definition to a stream in the specified format (XML, JSON, or YAML).
- WriteSchema(Schema, string, ConfigType, bool)
Writes a schema definition to a file in the specified format (XML, JSON, or YAML).
Events
- CommandCompletedLogUpdate
Event raised when a command completes execution, providing a log message.
- CommandInfoDetails
Event raised when a command completes, providing timing and performance information.
- CommandStartingLogUpdate
Event raised when a command starts execution, providing a log message.