Show / Hide Table of Contents

Class DataContextExtensions

Extension methods for IDataContext.

Inheritance
System.Object
DataContextExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Kephas.Data
Assembly: Kephas.Data.dll
Syntax
public static class DataContextExtensions

Methods

| Improve this Doc View Source

BulkDeleteAsync(IDataContext, IBulkDeleteContext, CancellationToken)

Deletes the entities matching the provided criteria and returns the number of affected entities asynchronously.

Declaration
public static Task<long> BulkDeleteAsync(this IDataContext dataContext, IBulkDeleteContext bulkDeleteContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

IBulkDeleteContext bulkDeleteContext

The bulk delete context.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A promise of the number of affected entities.

Remarks

The entities are physically removed from the database without invoking any behavior.

| Improve this Doc View Source

BulkDeleteAsync<T>(IDataContext, Expression<Func<T, Boolean>>, Boolean, CancellationToken)

Deletes the entities matching the provided criteria and returns the number of affected entities asynchronously.

Declaration
public static Task<long> BulkDeleteAsync<T>(this IDataContext dataContext, Expression<Func<T, bool>> criteria, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken))

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> criteria

The matching criteria for entities to delete.

System.Boolean throwIfNotFound

Optional. true to throw if not found.

System.Threading.CancellationToken cancellationToken

Optional. The cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A promise of the number of affected entities.

Type Parameters
Name Description
T

The type of the entity.

Remarks

The entities are physically removed from the database without invoking any behavior.

| Improve this Doc View Source

BulkUpdateAsync(IDataContext, IBulkUpdateContext, CancellationToken)

Updates the entities matching the provided criteria and returns the number of affected entities asynchronously.

Declaration
public static Task<long> BulkUpdateAsync(this IDataContext dataContext, IBulkUpdateContext bulkUpdateContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

IBulkUpdateContext bulkUpdateContext

The bulk update context.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A promise of the number of affected entities.

Remarks

The entities are physically updated in the database without invoking any behavior.

| Improve this Doc View Source

BulkUpdateAsync<T>(IDataContext, Expression<Func<T, Boolean>>, Object, Boolean, CancellationToken)

Updates the entities matching the provided criteria and returns the number of affected entities asynchronously.

Declaration
public static Task<long> BulkUpdateAsync<T>(this IDataContext dataContext, Expression<Func<T, bool>> criteria, object values, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken))

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> criteria

The matching criteria for entities to delete.

System.Object values

The values.

System.Boolean throwIfNotFound

Optional. true to throw if not found.

System.Threading.CancellationToken cancellationToken

Optional. The cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A promise of the number of affected entities.

Type Parameters
Name Description
T

The type of the entity.

Remarks

The entities are physically updated in the database without invoking any behavior.

| Improve this Doc View Source

CreateAsync(IDataContext, ICreateEntityContext, CancellationToken)

Creates asynchronously a new entity of the provided type and returns it.

Declaration
public static Task<object> CreateAsync(this IDataContext dataContext, ICreateEntityContext operationContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

ICreateEntityContext operationContext

Context for the create entity operation (optional).

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<System.Object>

A promise of the created entity.

| Improve this Doc View Source

CreateAsync(IDataContext, Type, CancellationToken)

Creates asynchronously a new entity of the provided type and returns it.

Declaration
public static Task<object> CreateAsync(this IDataContext dataContext, Type entityType, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.Type entityType

Type of the entity to create.

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<System.Object>

A promise of the created entity.

| Improve this Doc View Source

CreateAsync<T>(IDataContext, ICreateEntityContext, CancellationToken)

Creates asynchronously a new entity of the provided type and returns it.

Declaration
public static Task<T> CreateAsync<T>(this IDataContext dataContext, ICreateEntityContext operationContext, CancellationToken cancellationToken = default(CancellationToken))

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

ICreateEntityContext operationContext

Context for the create entity operation (optional).

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<T>

A promise of the created entity.

Type Parameters
Name Description
T

The type of the entity to create.

| Improve this Doc View Source

CreateAsync<T>(IDataContext, CancellationToken)

Creates asynchronously a new entity of the provided type and returns it.

Declaration
public static Task<T> CreateAsync<T>(this IDataContext dataContext, CancellationToken cancellationToken = default(CancellationToken))

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<T>

A promise of the created entity.

Type Parameters
Name Description
T

The type of the entity to create.

| Improve this Doc View Source

CreateCommand<TCommand>(IDataContext)

Creates the command with the provided type.

Declaration
public static TCommand CreateCommand<TCommand>(this IDataContext dataContext)

    where TCommand : IDataCommand
Parameters
Type Name Description
IDataContext dataContext

The data context.

Returns
Type Description
TCommand

The new command.

Type Parameters
Name Description
TCommand

The type of the command to be created.

| Improve this Doc View Source

Delete<T>(IDataContext, T[])

Marks the provided entity for deletion in the data context.

Declaration
public static void Delete<T>(this IDataContext dataContext, params T[] entities)

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

T[] entities

The entities to delete.

Type Parameters
Name Description
T

The type of the entity.

| Improve this Doc View Source

Delete<T>(IDataContext, IEnumerable<T>)

Marks the provided entities for deletion in the data context.

Declaration
public static void Delete<T>(this IDataContext dataContext, IEnumerable<T> entities)

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.Collections.Generic.IEnumerable<T> entities

The entities to delete.

Type Parameters
Name Description
T

The type of the entity.

| Improve this Doc View Source

Detach(IDataContext, Object)

Detaches the entity from the data context.

Declaration
public static IEntityEntry Detach(this IDataContext dataContext, object entity)
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.Object entity

The entity.

Returns
Type Description
IEntityEntry

The entity extended information.

| Improve this Doc View Source

DiscardChanges(IDataContext)

Discards the changes in the data context.

Declaration
public static IDataCommandResult DiscardChanges(this IDataContext dataContext)
Parameters
Type Name Description
IDataContext dataContext

The data context.

Returns
Type Description
IDataCommandResult

The result of discarding the changes.

| Improve this Doc View Source

ExecuteAsync(IDataContext, IExecuteContext, CancellationToken)

Executes the provided command in the data context.

Declaration
public static Task<object> ExecuteAsync(this IDataContext dataContext, IExecuteContext executeContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

IExecuteContext executeContext

Context for the execution.

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<System.Object>

A promise of the command execution result.

Exceptions
Type Condition
DataException

Thrown when a Data error condition occurs.

| Improve this Doc View Source

ExecuteAsync(IDataContext, String, CancellationToken)

Executes the provided command in the data context.

Declaration
public static Task<object> ExecuteAsync(this IDataContext dataContext, string commandText, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.String commandText

The command text.

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<System.Object>

A promise of the command execution result.

| Improve this Doc View Source

FindAsync(IDataContext, IFindContext, CancellationToken)

Searches for the entity with the provided ID and returns it asynchronously.

Declaration
public static Task<object> FindAsync(this IDataContext dataContext, IFindContext findContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

IFindContext findContext

Context for the find operation.

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<System.Object>

A promise of the found entity.

| Improve this Doc View Source

FindAsync(IDataContext, Type, Object, Boolean, CancellationToken)

Searches for the entity with the provided ID and returns it asynchronously.

Declaration
public static Task<object> FindAsync(this IDataContext dataContext, Type entityType, object id, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.Type entityType

Type of the entity.

System.Object id

The entity ID.

System.Boolean throwIfNotFound

If true and an entity with the provided ID is not found, an exception occurs (optional).

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<System.Object>

A promise of the found entity.

| Improve this Doc View Source

FindAsync<T>(IDataContext, IFindContext, CancellationToken)

Searches for the entity with the provided ID and returns it asynchronously.

Declaration
public static Task<T> FindAsync<T>(this IDataContext dataContext, IFindContext findContext, CancellationToken cancellationToken = default(CancellationToken))

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

IFindContext findContext

Context for the find operation.

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<T>

A promise of the found entity.

Type Parameters
Name Description
T

The type of the entity.

| Improve this Doc View Source

FindAsync<T>(IDataContext, Object, Boolean, CancellationToken)

Searches for the entity with the provided ID and returns it asynchronously.

Declaration
public static Task<T> FindAsync<T>(this IDataContext dataContext, object id, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken))

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.Object id

The entity ID.

System.Boolean throwIfNotFound

If true and an entity with the provided ID is not found, an exception occurs.

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<T>

A promise of the found entity.

Type Parameters
Name Description
T

The type of the entity.

| Improve this Doc View Source

FindOneAsync(IDataContext, IFindOneContext, CancellationToken)

Searches for the first entity matching the provided criteria and returns it asynchronously.

Declaration
public static Task<object> FindOneAsync(this IDataContext dataContext, IFindOneContext findContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

IFindOneContext findContext

The find context.

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<System.Object>

A promise of the found entity.

| Improve this Doc View Source

FindOneAsync<T>(IDataContext, IFindOneContext, CancellationToken)

Searches for the first entity matching the provided criteria and returns it asynchronously.

Declaration
public static Task<T> FindOneAsync<T>(this IDataContext dataContext, IFindOneContext findContext, CancellationToken cancellationToken = default(CancellationToken))

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

IFindOneContext findContext

The find context.

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<T>

A promise of the found entity.

Type Parameters
Name Description
T

The type of the entity.

| Improve this Doc View Source

FindOneAsync<T>(IDataContext, Expression<Func<T, Boolean>>, Boolean, CancellationToken)

Searches for the first entity matching the provided criteria and returns it asynchronously.

Declaration
public static Task<T> FindOneAsync<T>(this IDataContext dataContext, Expression<Func<T, bool>> criteria, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken))

    where T : class
Parameters
Type Name Description
IDataContext dataContext

The data context.

System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> criteria

The criteria.

System.Boolean throwIfNotFound

true to throw if not found (optional).

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<T>

A promise of the found entity.

Type Parameters
Name Description
T

The type of the entity.

| Improve this Doc View Source

PersistChangesAsync(IDataContext, IPersistChangesContext, CancellationToken)

Persists the changes in the dataContext asynchronously.

Declaration
public static Task<IDataCommandResult> PersistChangesAsync(this IDataContext dataContext, IPersistChangesContext persistContext = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IDataContext dataContext

The data context.

IPersistChangesContext persistContext

The context for persisting changes (optional).

System.Threading.CancellationToken cancellationToken

The cancellation token (optional).

Returns
Type Description
System.Threading.Tasks.Task<IDataCommandResult>

A promise of the persist result.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX