SchemaCheckResult Class
Assembly: CodeEffects.Rule.Connection.dll
Namespace: CodeEffects.Rule.Connection
Summary
Reports what a check of the Rule Repository database found: the schema version the database is at, the version the library that checked needs, and whether the database is current enough.
Syntax
public sealed class SchemaCheckResult
You never create this class. Context.CheckDatabase(dbProvider) of the Rule Repository library and AuditRecorder.CheckDatabase(dbProvider) of the Audit library return it. Call the method once at startup and stop, or log and go on, according to IsCurrent. Neither library calls it by itself, keeps the result, or changes the schema.
The schema version of a database is the number of the latest update script that was run on it. Update scripts are numbered in order, and the scripts come from the Code Effects portal; you run them against your database. Each library requires a minimum version. A database at a later version is fine, because a schema change in a minor version of the libraries only adds to the schema.
An application that never calls the check is told anyway, later: when a statement fails because a table or column is not there and the database is behind the library, the exception is a ConnectionException with the control number ConnectionException.SchemaBehind and the same message that Message holds.
A database that cannot be reached makes the check throw, as any other call does. That is not a schema to report on.
Properties
CurrentVersion
Type: System.Nullable<System.Int32>
Gets the schema version the database is at, or null when it records none. A database that records none was not created with the install script of the Rule Repository, or its version rows were removed.
IsCurrent
Type: System.Boolean
Gets a value that indicates whether the database is at the required version or later. It is false when CurrentVersion is null.
Message
Type: System.String
Gets what was found, in words, safe to log or show. When the database is current, the message says which version it is at and which the library needs. When it is behind, it names the update scripts to run from the Code Effects portal, in order. When it records no version, it says so.
RequiredVersion
Type: System.Int32
Gets the schema version that the library that checked needs.
Methods
ToString
Returns: System.String
Returns Message.
Parameters
Example
using System;
using CodeEffects.Rule.Connection;
using CodeEffects.Rule.Repository;
SchemaCheckResult check = Context.CheckDatabase(dbProvider);
if(!check.IsCurrent)
throw new InvalidOperationException(check.Message);
Console.WriteLine($"Schema {check.CurrentVersion}, needed {check.RequiredVersion}");