Class HiLoValueGeneratorState
- Namespace
- Microsoft.EntityFrameworkCore.ValueGeneration
- Assembly
- Microsoft.EntityFrameworkCore.dll
The thread safe state used by HiLoValueGenerator<TValue>.
public class HiLoValueGeneratorState : IDisposable
- Inheritance
-
HiLoValueGeneratorState
- Implements
- Inherited Members
Remarks
See EF Core value generation for more information and examples.
Constructors
HiLoValueGeneratorState(int)
Initializes a new instance of the HiLoValueGeneratorState class.
public HiLoValueGeneratorState(int blockSize)
Parameters
blockSize
intThe number of sequential values that can be used, starting from the low value, before a new low value must be fetched from the database.
Methods
Dispose()
Releases the allocated resources for this instance.
public virtual void Dispose()
NextAsync<TValue>(Func<CancellationToken, Task<long>>, CancellationToken)
Gets a value to be assigned to a property.
public virtual ValueTask<TValue> NextAsync<TValue>(Func<CancellationToken, Task<long>> getNewLowValue, CancellationToken cancellationToken = default)
Parameters
getNewLowValue
Func<CancellationToken, Task<long>>A function to get the next low value if needed.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<TValue>
The value to be assigned to a property.
Type Parameters
TValue
The type of values being generated.
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
Next<TValue>(Func<long>)
Gets a value to be assigned to a property.
public virtual TValue Next<TValue>(Func<long> getNewLowValue)
Parameters
Returns
- TValue
The value to be assigned to a property.
Type Parameters
TValue
The type of values being generated.