Table of Contents

Class ConcurrencyExtensions

Namespace
LinqToDB.Concurrency
Assembly
linq2db.dll
public static class ConcurrencyExtensions
Inheritance
ConcurrencyExtensions

Methods

DeleteOptimisticAsync<T>(IDataContext, T, CancellationToken)

Performs record delete using optimistic lock strategy asynchronously. Entity should have column annotated with OptimisticLockPropertyBaseAttribute, otherwise regular delete operation will be performed.

public static Task<int> DeleteOptimisticAsync<T>(this IDataContext dc, T obj, CancellationToken cancellationToken = default) where T : class

Parameters

dc IDataContext

Database context.

obj T

Entity instance to delete.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<int>

Number of deleted records.

Type Parameters

T

Entity type.

DeleteOptimisticAsync<T>(IQueryable<T>, T, CancellationToken)

Performs record delete using optimistic lock strategy asynchronously. Entity should have column annotated with OptimisticLockPropertyBaseAttribute, otherwise regular delete operation will be performed.

public static Task<int> DeleteOptimisticAsync<T>(this IQueryable<T> source, T obj, CancellationToken cancellationToken = default) where T : class

Parameters

source IQueryable<T>

Table source with optional filtering applied.

obj T

Entity instance to delete.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<int>

Number of deleted records.

Type Parameters

T

Entity type.

DeleteOptimistic<T>(IDataContext, T)

Performs record delete using optimistic lock strategy. Entity should have column annotated with OptimisticLockPropertyBaseAttribute, otherwise regular delete operation will be performed.

public static int DeleteOptimistic<T>(this IDataContext dc, T obj) where T : class

Parameters

dc IDataContext

Database context.

obj T

Entity instance to delete.

Returns

int

Number of deleted records.

Type Parameters

T

Entity type.

DeleteOptimistic<T>(IQueryable<T>, T)

Performs record delete using optimistic lock strategy. Entity should have column annotated with OptimisticLockPropertyBaseAttribute, otherwise regular delete operation will be performed.

public static int DeleteOptimistic<T>(this IQueryable<T> source, T obj) where T : class

Parameters

source IQueryable<T>

Table source with optional filtering applied.

obj T

Entity instance to delete.

Returns

int

Number of deleted records.

Type Parameters

T

Entity type.

UpdateOptimisticAsync<T>(IDataContext, T, CancellationToken)

Performs record update using optimistic lock strategy asynchronously. Entity should have column annotated with OptimisticLockPropertyBaseAttribute, otherwise regular update operation will be performed.

public static Task<int> UpdateOptimisticAsync<T>(this IDataContext dc, T obj, CancellationToken cancellationToken = default) where T : class

Parameters

dc IDataContext

Database context.

obj T

Entity instance to update.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<int>

Number of updated records.

Type Parameters

T

Entity type.

UpdateOptimisticAsync<T>(IQueryable<T>, T, CancellationToken)

Performs record update using optimistic lock strategy asynchronously. Entity should have column annotated with OptimisticLockPropertyBaseAttribute, otherwise regular update operation will be performed.

public static Task<int> UpdateOptimisticAsync<T>(this IQueryable<T> source, T obj, CancellationToken cancellationToken = default) where T : class

Parameters

source IQueryable<T>

Table source with optional filtering applied.

obj T

Entity instance to update.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<int>

Number of updated records.

Type Parameters

T

Entity type.

UpdateOptimistic<T>(IDataContext, T)

Performs record update using optimistic lock strategy. Entity should have column annotated with OptimisticLockPropertyBaseAttribute, otherwise regular update operation will be performed.

public static int UpdateOptimistic<T>(this IDataContext dc, T obj) where T : class

Parameters

dc IDataContext

Database context.

obj T

Entity instance to update.

Returns

int

Number of updated records.

Type Parameters

T

Entity type.

UpdateOptimistic<T>(IQueryable<T>, T)

Performs record update using optimistic lock strategy. Entity should have column annotated with OptimisticLockPropertyBaseAttribute, otherwise regular update operation will be performed.

public static int UpdateOptimistic<T>(this IQueryable<T> source, T obj) where T : class

Parameters

source IQueryable<T>

Table source with optional filtering applied.

obj T

Entity instance to update.

Returns

int

Number of updated records.

Type Parameters

T

Entity type.

WhereKeyOptimistic<T>(IQueryable<T>, T)

Applies primary key and optimistic lock filters to query for specific record. Entity should have column annotated with OptimisticLockPropertyBaseAttribute, otherwise only primary key filter will be applied to query.

public static IQueryable<T> WhereKeyOptimistic<T>(this IQueryable<T> source, T obj) where T : class

Parameters

source IQueryable<T>

Entity query.

obj T

Entity instance to take current lock field value from.

Returns

IQueryable<T>

Query with filter over lock field.

Type Parameters

T

Entity type.