Class GroupedDataLoader<TKey, TValue>
- Namespace
- GreenDonut
- Assembly
- GreenDonut.dll
The GroupedDataLoader is used to fetch a collection of items for a single provided key in a batch.
public abstract class GroupedDataLoader<TKey, TValue> : DataLoaderBase<TKey, TValue[]>, IDataLoader<TKey, TValue[]>, IDataLoader, IDisposable where TKey : notnull
Type Parameters
TKey
A key type.
TValue
A value type.
- Inheritance
-
DataLoaderBase<TKey, TValue[]>GroupedDataLoader<TKey, TValue>
- Implements
-
IDataLoader<TKey, TValue[]>
- Inherited Members
- Extension Methods
Constructors
GroupedDataLoader(IBatchScheduler, DataLoaderOptions?)
Initializes a new instance of the GroupedDataLoader<TKey, TValue> class.
protected GroupedDataLoader(IBatchScheduler batchScheduler, DataLoaderOptions? options = null)
Parameters
batchScheduler
IBatchSchedulerA scheduler to tell the
DataLoader
when to dispatch buffered batches.options
DataLoaderOptionsAn options object to configure the behavior of this particular GroupedDataLoader<TKey, TValue>.
Exceptions
- ArgumentNullException
Throws if
options
isnull
.
Methods
FetchAsync(IReadOnlyList<TKey>, Memory<Result<TValue[]>>, CancellationToken)
protected override sealed ValueTask FetchAsync(IReadOnlyList<TKey> keys, Memory<Result<TValue[]>> results, CancellationToken cancellationToken)
Parameters
keys
IReadOnlyList<TKey>results
Memory<Result<TValue[]>>cancellationToken
CancellationToken
Returns
LoadGroupedBatchAsync(IReadOnlyList<TKey>, CancellationToken)
Loads the data for a grouped batch from the data source.
protected abstract Task<ILookup<TKey, TValue>> LoadGroupedBatchAsync(IReadOnlyList<TKey> keys, CancellationToken cancellationToken)
Parameters
keys
IReadOnlyList<TKey>The keys that shall be fetched in a batch.
cancellationToken
CancellationTokenThe cancellation token.