Table of Contents

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 IDataLoader

A data loader instance.

key object

A 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 is null.

ArgumentNullException

Throws if key is null.

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 IDataLoader

A 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 is null.

ArgumentNullException

Throws if keys is null.

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 IDataLoader

A data loader instance.

cancellationToken CancellationToken

The 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 is null.

ArgumentNullException

Throws if keys is null.

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 CancellationToken

The 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 is null.

ArgumentNullException

Throws if keys is null.

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 is null.

ArgumentNullException

Throws if keys is null.

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 IDataLoader

A data loader instance.

key object

A cache entry key.

value object

A cache entry value.

Exceptions

ArgumentNullException

Throws if dataLoader is null.

ArgumentNullException

Throws if key is null.

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 TKey

A cache entry key.

value TValue

A cache entry value.

Type Parameters

TKey

A key type.

TValue

A value type.

Exceptions

ArgumentNullException

Throws if dataLoader is null.

ArgumentNullException

Throws if key is null.