Show / Hide Table of Contents

    Class DatabaseSchemaCache

    Implementation of IDatabaseSchemaCache. It allows to load database schemas after adding appropriate loaders (AddSchemaLoader(IDatabaseSchemaLoader, ISchemaCacheKeyGenerator)). Loading of a database schema is quite slow, that's why loaded schemas are cached. On next request for the same schema, it is not loaded from database, but returned from cache.

    Inheritance
    System.Object
    DatabaseSchemaCache
    Implements
    IDatabaseSchemaCache
    Namespace: Kros.Data.Schema
    Assembly: Kros.Utils.dll
    Syntax
    public class DatabaseSchemaCache : IDatabaseSchemaCache
    Remarks

    It is necessary to initialize DatabaseSchemaCache with loaders (IDatabaseSchemaLoader) and every loader must have its cache key generator (ISchemaCacheKeyGenerator). Different cache key generators should generate different keys.

    There is a property Default intended for simple static use, so it is not necessary to create own instance.

    Properties

    Default

    Instance of DatabaseSchemaCache intended for simple static use. By default, it contains a loader for Microsoft SQL Server (SqlServerSchemaLoader).

    Declaration
    public static DatabaseSchemaCache Default { get; }
    Property Value
    Type Description
    DatabaseSchemaCache

    Methods

    AddSchemaLoader(IDatabaseSchemaLoader, ISchemaCacheKeyGenerator)

    Adds loader together with its cache key generator keyGenerator to the inner loaders list.

    Declaration
    public void AddSchemaLoader(IDatabaseSchemaLoader loader, ISchemaCacheKeyGenerator keyGenerator)
    Parameters
    Type Name Description
    IDatabaseSchemaLoader loader

    Database schema loader.

    ISchemaCacheKeyGenerator keyGenerator

    Schema cache key generator for loader.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Value of loader or keyGenerator is null.

    ClearAllSchemas()

    Declaration
    public void ClearAllSchemas()

    ClearSchema(Object)

    Declaration
    public void ClearSchema(object connection)
    Parameters
    Type Name Description
    System.Object connection
    Exceptions
    Type Condition
    System.InvalidOperationException

    The cache does not contain a loader for database type specified by connection.

    ClearSchemaLoaders()

    Removes all database schema loaders.

    Declaration
    public void ClearSchemaLoaders()

    GetSchema(Object)

    Declaration
    public DatabaseSchema GetSchema(object connection)
    Parameters
    Type Name Description
    System.Object connection
    Returns
    Type Description
    DatabaseSchema
    Exceptions
    Type Condition
    System.InvalidOperationException

    The cache does not contain a loader for database type specified by connection.

    RefreshSchema(Object)

    Declaration
    public DatabaseSchema RefreshSchema(object connection)
    Parameters
    Type Name Description
    System.Object connection
    Returns
    Type Description
    DatabaseSchema
    Exceptions
    Type Condition
    System.InvalidOperationException

    The cache does not contain a loader for database type specified by connection.

    RemoveSchemaLoader(IDatabaseSchemaLoader)

    Removes specified loader from inner loaders list.

    Declaration
    public void RemoveSchemaLoader(IDatabaseSchemaLoader loader)
    Parameters
    Type Name Description
    IDatabaseSchemaLoader loader

    Database schema loader to be removed.

    Implements

    IDatabaseSchemaCache
    Back to top KROS a.s.