Struct DatabaseInfo
- Namespace
- YndigoBlue.Velocity.Model
- Assembly
- YndigoBlue.Velocity.dll
Contains metadata about the database server that Velocity is connected to.
public struct DatabaseInfo
Remarks
DatabaseInfo captures version and vendor information from the connected database server. This information is useful for understanding which database features are available, performing version-specific operations, and diagnostic logging.
Velocity retrieves this information when connecting to a database through Manager. The specific details returned depend on the database system (SQL Server, PostgreSQL, MySQL, etc.).
Examples
Retrieving database information:
using (Manager manager = new Manager(connection))
{
DatabaseInfo dbInfo = manager.GetDatabaseInfo();
Console.WriteLine($"Vendor: {dbInfo.Vendor}");
Console.WriteLine($"Name: {dbInfo.Name}");
Console.WriteLine($"Edition: {dbInfo.Edition}");
Console.WriteLine($"Version: {dbInfo.MajorVersion}.{dbInfo.MinorVersion}");
// Full string representation
Console.WriteLine(dbInfo.ToString());
// Output: "Microsoft SQL Server (Developer Edition 16.0)"
}
Version-specific behavior:
DatabaseInfo dbInfo = manager.GetDatabaseInfo();
// Check for specific database version support
if (dbInfo.Vendor == "PostgreSQL" && dbInfo.MajorVersion >= 12)
{
// Use PostgreSQL 12+ features
Console.WriteLine("Generated columns supported");
}
if (dbInfo.Name == "SQL Server" && dbInfo.MajorVersion >= 16)
{
// Use SQL Server 2022+ features
Console.WriteLine("JSON functions available");
}
Diagnostic logging:
DatabaseInfo dbInfo = manager.GetDatabaseInfo();
// Log connection details for troubleshooting
Logger.Info($"Connected to: {dbInfo}");
// Output: "Microsoft SQL Server (Developer Edition 16.0)"
// Check for specific editions
if (dbInfo.Edition.Contains("Express"))
{
Console.WriteLine("WARNING: Express Edition has database size limits");
}
Properties
- Edition
Gets or sets the database edition.
- MajorVersion
Gets or sets the major version number of the database server.
- MinorVersion
Gets or sets the minor version number of the database server.
- Name
Gets or sets the database product name.
- Vendor
Gets or sets the database vendor name.
Methods
- ToString()
Returns a formatted string representation of the database information.