Search Results for

    Show / Hide Table of Contents
    View Source

    Class DbContextExtensions

    Provides extension methods for Entity Framework Core DbContext operations.

    Inheritance
    object
    Namespace: Umbraco.Extensions
    Assembly: Umbraco.Cms.Persistence.EFCore.dll
    Syntax
    public static class DbContextExtensions

    Methods

    View Source

    ExecuteScalarAsync<T>(DatabaseFacade, string, List<DbParameter>?, CommandType, TimeSpan?)

    Executes a raw SQL query and returns the result.

    Declaration
    public static Task<T?> ExecuteScalarAsync<T>(this DatabaseFacade database, string sql, List<DbParameter>? parameters = null, CommandType commandType = CommandType.Text, TimeSpan? commandTimeOut = null)
    Parameters
    Type Name Description
    DatabaseFacade database

    The database.

    string sql

    The sql query.

    List<DbParameter> parameters

    The list of db parameters.

    CommandType commandType

    The command type.

    TimeSpan? commandTimeOut

    The amount of time to wait before the command times out.

    Returns
    Type Description
    Task<T>

    Returns an object of the given type T.

    Type Parameters
    Name Description
    T

    the type to return.

    View Source

    MigrateDatabaseAsync(DbContext, string)

    Migrates the database to a specific migration identified by its ID.

    Declaration
    public static Task MigrateDatabaseAsync(this DbContext context, string targetMigrationId)
    Parameters
    Type Name Description
    DbContext context

    The database context.

    string targetMigrationId

    The ID of the target migration.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    View Source

    MigrateDatabaseAsync(DbContext, Type)

    Migrates the database to a specific migration identified by its type.

    Declaration
    public static Task MigrateDatabaseAsync(this DbContext context, Type targetMigration)
    Parameters
    Type Name Description
    DbContext context

    The database context.

    Type targetMigration

    The type of the target migration.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the type does not have a MigrationAttribute.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX