Search Results for

    Show / Hide Table of Contents
    View Source

    Class UmbracoDatabaseFactory

    Default implementation of IUmbracoDatabaseFactory.

    Inheritance
    System.Object
    DisposableObjectSlim
    Namespace: Umbraco.Cms.Infrastructure.Persistence
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public class UmbracoDatabaseFactory : DisposableObjectSlim, IUmbracoDatabaseFactory
    Remarks

    This factory implementation creates and manages an "ambient" database connection. When running within an Http context, "ambient" means "associated with that context". Otherwise, it means "static to the current thread". In this latter case, note that the database connection object is not thread safe.

    It wraps an NPoco UmbracoDatabaseFactory which is initializes with a proper IPocoDataFactory to ensure that NPoco's plumbing is cached appropriately for the whole application.

    Constructors

    View Source

    UmbracoDatabaseFactory(ILogger<UmbracoDatabaseFactory>, ILoggerFactory, IOptions<GlobalSettings>, IOptionsMonitor<ConnectionStrings>, IMapperCollection, IDbProviderFactoryCreator, DatabaseSchemaCreatorFactory, NPocoMapperCollection)

    Initializes a new instance of the UmbracoDatabaseFactory.

    Declaration
    public UmbracoDatabaseFactory(ILogger<UmbracoDatabaseFactory> logger, ILoggerFactory loggerFactory, IOptions<GlobalSettings> globalSettings, IOptionsMonitor<ConnectionStrings> connectionStrings, IMapperCollection mappers, IDbProviderFactoryCreator dbProviderFactoryCreator, DatabaseSchemaCreatorFactory databaseSchemaCreatorFactory, NPocoMapperCollection npocoMappers)
    Parameters
    Type Name Description
    ILogger<UmbracoDatabaseFactory> logger
    ILoggerFactory loggerFactory
    IOptions<GlobalSettings> globalSettings
    IOptionsMonitor<ConnectionStrings> connectionStrings
    IMapperCollection mappers
    IDbProviderFactoryCreator dbProviderFactoryCreator
    DatabaseSchemaCreatorFactory databaseSchemaCreatorFactory
    NPocoMapperCollection npocoMappers
    Remarks

    Used by the other ctor and in tests.

    Properties

    View Source

    BulkSqlInsertProvider

    Gets the IBulkSqlInsertProvider.

    Declaration
    public IBulkSqlInsertProvider BulkSqlInsertProvider { get; }
    Property Value
    Type Description
    IBulkSqlInsertProvider
    Remarks

    Getting the IBulkSqlInsertProvider causes the factory to initialize if it is not already initialized.

    View Source

    CanConnect

    Gets a value indicating whether the database factory is configured (see Configured), and it is possible to connect to the database. The factory may however not be initialized (see Initialized).

    Declaration
    public bool CanConnect { get; }
    Property Value
    Type Description
    System.Boolean
    View Source

    Configured

    Gets a value indicating whether the database factory is configured, i.e. whether its connection string and provider name have been set. The factory may however not be initialized (see Initialized).

    Declaration
    public bool Configured { get; }
    Property Value
    Type Description
    System.Boolean
    View Source

    ConnectionString

    Gets the connection string.

    Declaration
    public string ConnectionString { get; }
    Property Value
    Type Description
    System.String
    Remarks

    May return null if the database factory is not configured.

    View Source

    Initialized

    Gets a value indicating whether the database factory is initialized, i.e. whether its internal state is ready and it has been possible to connect to the database.

    Declaration
    public bool Initialized { get; }
    Property Value
    Type Description
    System.Boolean
    View Source

    ProviderName

    Gets the provider name.

    Declaration
    public string ProviderName { get; }
    Property Value
    Type Description
    System.String
    Remarks

    May return null if the database factory is not configured.

    View Source

    SqlContext

    Gets the ISqlContext.

    Declaration
    public ISqlContext SqlContext { get; }
    Property Value
    Type Description
    ISqlContext
    Remarks

    Getting the ISqlContext causes the factory to initialize if it is not already initialized.

    Methods

    View Source

    Configure(ConnectionStrings)

    Configures the database factory.

    Declaration
    public void Configure(ConnectionStrings umbracoConnectionString)
    Parameters
    Type Name Description
    ConnectionStrings umbracoConnectionString
    View Source

    ConfigureForUpgrade()

    Configures the database factory for upgrades.

    Declaration
    public void ConfigureForUpgrade()
    View Source

    CreateDatabase()

    Creates a new database.

    Declaration
    public IUmbracoDatabase CreateDatabase()
    Returns
    Type Description
    IUmbracoDatabase
    Remarks

    The new database must be disposed after being used.

    Creating a database causes the factory to initialize if it is not already initialized.

    View Source

    DisposeResources()

    Declaration
    protected override void DisposeResources()
    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • UmbracoDatabaseFactory(ILogger<UmbracoDatabaseFactory>, ILoggerFactory, IOptions<GlobalSettings>, IOptionsMonitor<ConnectionStrings>, IMapperCollection, IDbProviderFactoryCreator, DatabaseSchemaCreatorFactory, NPocoMapperCollection)
    • Properties
      • BulkSqlInsertProvider
      • CanConnect
      • Configured
      • ConnectionString
      • Initialized
      • ProviderName
      • SqlContext
    • Methods
      • Configure(ConnectionStrings)
      • ConfigureForUpgrade()
      • CreateDatabase()
      • DisposeResources()
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX