Table of Contents

Class HiLoValueGenerator<TValue>

Namespace
Microsoft.EntityFrameworkCore.ValueGeneration
Assembly
Microsoft.EntityFrameworkCore.dll

Acts as a ValueGenerator by requesting a block of values from the underlying database and returning them one by one. Will ask the underlying database for another block when the current block is exhausted.

public abstract class HiLoValueGenerator<TValue> : ValueGenerator<TValue>

Type Parameters

TValue

The type of values that are generated.

Inheritance
HiLoValueGenerator<TValue>
Inherited Members

Remarks

A block is represented by a low value fetched from the database, and then a block size that indicates how many sequential values can be used, starting from the low value, before a new low value must be fetched from the database.

Constructors

HiLoValueGenerator(HiLoValueGeneratorState)

Initializes a new instance of the HiLoValueGenerator<TValue> class.

protected HiLoValueGenerator(HiLoValueGeneratorState generatorState)

Parameters

generatorState HiLoValueGeneratorState

The state used to keep track of which value to return next.

Methods

GetNewLowValue()

Gets the low value for the next block of values to be used.

protected abstract long GetNewLowValue()

Returns

long

The low value for the next block of values to be used.

GetNewLowValueAsync(CancellationToken)

Gets the low value for the next block of values to be used.

protected virtual Task<long> GetNewLowValueAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<long>

The low value for the next block of values to be used.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

Next(EntityEntry)

Gets a value to be assigned to a property.

public override TValue Next(EntityEntry entry)

Parameters

entry EntityEntry

The change tracking entry of the entity for which the value is being generated.

Returns

TValue

The value to be assigned to a property.

NextAsync(EntityEntry, CancellationToken)

Gets a value to be assigned to a property.

public override ValueTask<TValue> NextAsync(EntityEntry entry, CancellationToken cancellationToken = default)

Parameters

entry EntityEntry

The change tracking entry of the entity for which the value is being generated.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask<TValue>

The value to be assigned to a property.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.