Class DataLoaderExtensions
- Namespace
- GreenDonut
- Assembly
- GreenDonut.dll
A bunch of convenient DataLoader
extension methods.
public static class DataLoaderExtensions
- Inheritance
-
DataLoaderExtensions
- Inherited Members
Methods
LoadAsync(IDataLoader, object)
Loads a single value by key. This call may return a cached value or enqueues this single request for batching if enabled.
public static Task<object?> LoadAsync(this IDataLoader dataLoader, object key)
Parameters
dataLoader
IDataLoaderA data loader instance.
key
objectA unique key.
Returns
- Task<object>
A single result which may contain a value or information about the error which may occurred during the call.
Exceptions
- ArgumentNullException
Throws if
dataLoader
isnull
.- ArgumentNullException
Throws if
key
isnull
.
LoadAsync(IDataLoader, params object[])
Loads multiple values by keys. This call may return cached values and enqueues requests which were not cached for batching if enabled.
public static Task<IReadOnlyList<object?>> LoadAsync(this IDataLoader dataLoader, params object[] keys)
Parameters
dataLoader
IDataLoaderA data loader instance.
keys
object[]A list of unique key.
Returns
- Task<IReadOnlyList<object>>
A single result which may contain a value or information about the error which may occurred during the call.
Exceptions
- ArgumentNullException
Throws if
dataLoader
isnull
.- ArgumentNullException
Throws if
keys
isnull
.
LoadAsync(IDataLoader, CancellationToken, params object[])
Loads multiple values by keys. This call may return cached values and enqueues requests which were not cached for batching if enabled.
public static Task<IReadOnlyList<object?>> LoadAsync(this IDataLoader dataLoader, CancellationToken cancellationToken, params object[] keys)
Parameters
dataLoader
IDataLoaderA data loader instance.
cancellationToken
CancellationTokenThe cancellation token.
keys
object[]A list of unique key.
Returns
- Task<IReadOnlyList<object>>
A single result which may contain a value or information about the error which may occurred during the call.
Exceptions
- ArgumentNullException
Throws if
dataLoader
isnull
.- ArgumentNullException
Throws if
keys
isnull
.
LoadAsync<TKey, TValue>(IDataLoader<TKey, TValue>, CancellationToken, params TKey[])
Loads multiple values by keys. This call may return cached values and enqueues requests which were not cached for batching if enabled.
public static Task<IReadOnlyList<TValue>> LoadAsync<TKey, TValue>(this IDataLoader<TKey, TValue> dataLoader, CancellationToken cancellationToken, params TKey[] keys) where TKey : notnull
Parameters
dataLoader
IDataLoader<TKey, TValue>A data loader instance.
cancellationToken
CancellationTokenThe cancellation token.
keys
TKey[]A list of unique key.
Returns
- Task<IReadOnlyList<TValue>>
A single result which may contain a value or information about the error which may occurred during the call.
Type Parameters
TKey
A key type.
TValue
A value type.
Exceptions
- ArgumentNullException
Throws if
dataLoader
isnull
.- ArgumentNullException
Throws if
keys
isnull
.
LoadAsync<TKey, TValue>(IDataLoader<TKey, TValue>, params TKey[])
Loads multiple values by keys. This call may return cached values and enqueues requests which were not cached for batching if enabled.
public static Task<IReadOnlyList<TValue>> LoadAsync<TKey, TValue>(this IDataLoader<TKey, TValue> dataLoader, params TKey[] keys) where TKey : notnull
Parameters
dataLoader
IDataLoader<TKey, TValue>A data loader instance.
keys
TKey[]A list of unique key.
Returns
- Task<IReadOnlyList<TValue>>
A single result which may contain a value or information about the error which may occurred during the call.
Type Parameters
TKey
A key type.
TValue
A value type.
Exceptions
- ArgumentNullException
Throws if
dataLoader
isnull
.- ArgumentNullException
Throws if
keys
isnull
.
Set(IDataLoader, object, object?)
Adds a new entry to the cache if not already exists.
public static void Set(this IDataLoader dataLoader, object key, object? value)
Parameters
dataLoader
IDataLoaderA data loader instance.
key
objectA cache entry key.
value
objectA cache entry value.
Exceptions
- ArgumentNullException
Throws if
dataLoader
isnull
.- ArgumentNullException
Throws if
key
isnull
.
Set<TKey, TValue>(IDataLoader<TKey, TValue>, TKey, TValue)
Adds a new entry to the cache if not already exists.
public static void Set<TKey, TValue>(this IDataLoader<TKey, TValue> dataLoader, TKey key, TValue value) where TKey : notnull
Parameters
dataLoader
IDataLoader<TKey, TValue>A data loader instance.
key
TKeyA cache entry key.
value
TValueA cache entry value.
Type Parameters
TKey
A key type.
TValue
A value type.
Exceptions
- ArgumentNullException
Throws if
dataLoader
isnull
.- ArgumentNullException
Throws if
key
isnull
.