Class DatabaseVersionValidator
Validates the database version against the supported assembly version.
Inheritance
Implements
Inherited Members
Namespace: EPiServer.Data
Assembly: EPiServer.Data.dll
Version: 9.12.2Syntax
[ServiceConfiguration(typeof(IDatabaseSchemaUpdater))]
public class DatabaseVersionValidator : IDatabaseSchemaUpdater
Constructors
DatabaseVersionValidator(IDatabaseHandler)
Initializes a new instance of the DatabaseVersionValidator class.
Declaration
[Obsolete("Use another constructor")]
public DatabaseVersionValidator(IDatabaseHandler databaseHandler)
Parameters
Type | Name | Description |
---|---|---|
IDatabaseHandler | databaseHandler |
DatabaseVersionValidator(IDatabaseHandler, ScriptExecutor)
Initializes a new instance of the DatabaseVersionValidator class.
Declaration
public DatabaseVersionValidator(IDatabaseHandler databaseHandler, ScriptExecutor scriptExecutor)
Parameters
Type | Name | Description |
---|---|---|
IDatabaseHandler | databaseHandler | |
ScriptExecutor | scriptExecutor |
Methods
GetDatabaseVersion()
Gets the database version.
Declaration
public virtual Version GetDatabaseVersion()
Returns
Type | Description |
---|---|
System.Version |
GetStatus(ConnectionStringsSection)
Called during startup to collect status of the databases.
Declaration
public DatabaseSchemaStatus GetStatus(ConnectionStringsSection connectionStrings)
Parameters
Type | Name | Description |
---|---|---|
System.Configuration.ConnectionStringsSection | connectionStrings | The current configured connection strings. |
Returns
Type | Description |
---|---|
DatabaseSchemaStatus | The handled database and the current version of the database. |
ThrowUpdateCodeException(Version, Version)
Throws an NotSupportedException exception saying that packages needs to be updated.
Declaration
public virtual void ThrowUpdateCodeException(Version databaseVersion, Version codeVersion)
Parameters
Type | Name | Description |
---|---|---|
System.Version | databaseVersion | The database version |
System.Version | codeVersion | The .NET code version |
ThrowUpdateDatabaseException(Version, Version)
Throws an NotSupportedException exception saying that database needs to be updated.
Declaration
public virtual void ThrowUpdateDatabaseException(Version databaseVersion, Version codeVersion)
Parameters
Type | Name | Description |
---|---|---|
System.Version | databaseVersion | The database version |
System.Version | codeVersion | The .NET code version |
Update(ConnectionStringSettings)
Called during startup if result from GetStatus(ConnectionStringsSection) indicates that an update is required.
Declaration
public void Update(ConnectionStringSettings connectionStringSettings)
Parameters
Type | Name | Description |
---|---|---|
System.Configuration.ConnectionStringSettings | connectionStringSettings | The connection string settings returned from GetStatus(ConnectionStringsSection) |
Remarks
An update is considered to be required if the DatabaseVersion is undefined and
CreateDatabaseSchema is true
OR
if the DatabaseVersion is lower than ApplicationRequiredVersion.
and UpdateDatabaseSchema is true
AND
no IDatabaseSchemaValidator implemenations return false
from method
IsDatabaseUpdateAllowed(ConnectionStringSettings).
ValidateDatabaseVersion(Version)
Validates the database version.
Declaration
public virtual void ValidateDatabaseVersion(Version supportedVersion)
Parameters
Type | Name | Description |
---|---|---|
System.Version | supportedVersion |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Will be thrown if the database version not maches the supported version. |