Show / Hide Table of Contents

Class DbContextExtensions

Extension methods for Microsoft.EntityFrameworkCore.DbContext.

Inheritance
Object
DbContextExtensions
Inherited Members
Object.Equals(Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: IRM.EntityFrameworkCore
Assembly: IRM.EntityFrameworkCore.dll
Syntax
public static class DbContextExtensions

Methods

GetWithProcedure<TAggregateList>(DbContext, String, DbParameter[], ITranslate<TAggregateList, IDataReader>, Int32)

Gets a collection of aggregates by executing a stored procedure. This is useful when extreme optimization of performance is required.

Declaration
public static TAggregateList GetWithProcedure<TAggregateList>(this DbContext context, string procedureName, DbParameter[] parameters, ITranslate<TAggregateList, IDataReader> translator, int commandTimeout = 120)
    where TAggregateList : class, IEnumerable
Parameters
Microsoft.EntityFrameworkCore.DbContext context

The Microsoft.EntityFrameworkCore.DbContext to get the connection from.

String procedureName

The name of the stored procedure to execute.

DbParameter[] parameters

The parameters to the stored procedure.

ITranslate<TAggregateList, System.Data.IDataReader> translator

The translator used to translate the System.Data.IDataReader to the collection of aggregates.

System.Int32 commandTimeout

The required timeout of the execution of the procedure.

Returns
TAggregateList

A collection of aggregates.

Type Parameters
TAggregateList

The type of collection and the type of aggregate.

IsAllMigrationsApplied(DbContext)

Gets if all migrations is applied in the database or not.

Declaration
public static bool IsAllMigrationsApplied(this DbContext context)
Parameters
Microsoft.EntityFrameworkCore.DbContext context

The Microsoft.EntityFrameworkCore.DbContext to check migrations for.

Returns
Boolean

true if all migrations is applied; otherwise false.

IsAllMigrationsAppliedAsync(DbContext)

Gets if all migrations is applied in the database or not.

Declaration
public static async Task<bool> IsAllMigrationsAppliedAsync(this DbContext context)
Parameters
Microsoft.EntityFrameworkCore.DbContext context

The Microsoft.EntityFrameworkCore.DbContext to check migrations for.

Returns
System.Threading.Tasks.Task<Boolean>

true if all migrations is applied; otherwise false.

MigrateIfNeeded(DbContext)

Applies all migrations in the database if it isn't already.

Declaration
public static void MigrateIfNeeded(this DbContext context)
Parameters
Microsoft.EntityFrameworkCore.DbContext context

The Microsoft.EntityFrameworkCore.DbContext to migrate if needed.

MigrateIfNeededAsync(DbContext)

Applies all migrations in the database if it isn't already.

Declaration
public static async Task MigrateIfNeededAsync(this DbContext context)
Parameters
Microsoft.EntityFrameworkCore.DbContext context

The Microsoft.EntityFrameworkCore.DbContext to migrate if needed.

Returns
System.Threading.Tasks.Task

Back to top Generated by DocFX