Class MaybeLinqExtensionsTaskAsync
- Namespace
- Trellis
- Assembly
- Trellis.Core.dll
Provides LINQ query expression support for Task<TResult> of Maybe<T>, enabling C# query syntax over fully asynchronous Maybe-returning operations.
public static class MaybeLinqExtensionsTaskAsync
- Inheritance
-
MaybeLinqExtensionsTaskAsync
- Inherited Members
Remarks
These overloads match the C# query-pattern signatures (Select, SelectMany, Where)
for an async receiver and async continuations. With them, from x in FindAsync() compiles when
FindAsync() returns Task<Maybe<T>>, removing the need to await each
step and re-enter a sync query block.
The semantics mirror the synchronous MaybeLinqExtensions overloads: a None
short-circuits subsequent steps; only present values are passed to the next selector.
Methods
SelectMany<TSource, TCollection, TResult>(Task<Maybe<TSource>>, Func<TSource, Task<Maybe<TCollection>>>, Func<TSource, TCollection, TResult>)
Projects the value of an awaited Maybe<T> through an async collection selector
and combines the results (LINQ SelectMany over async/async).
public static Task<Maybe<TResult>> SelectMany<TSource, TCollection, TResult>(this Task<Maybe<TSource>> source, Func<TSource, Task<Maybe<TCollection>>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector) where TSource : notnull where TCollection : notnull where TResult : notnull
Parameters
sourceTask<Maybe<TSource>>The asynchronous source Maybe.
collectionSelectorFunc<TSource, Task<Maybe<TCollection>>>An async function returning the intermediate Maybe.
resultSelectorFunc<TSource, TCollection, TResult>A synchronous function combining the source and intermediate values.
Returns
Type Parameters
TSourceType of the source value.
TCollectionType of the intermediate collection value.
TResultType of the final projected value.
Select<TIn, TOut>(Task<Maybe<TIn>>, Func<TIn, TOut>)
Projects the value of an awaited Maybe<T> using a synchronous selector
(LINQ Select over Task<TResult>).
public static Task<Maybe<TOut>> Select<TIn, TOut>(this Task<Maybe<TIn>> maybeTask, Func<TIn, TOut> selector) where TIn : notnull where TOut : notnull
Parameters
maybeTaskTask<Maybe<TIn>>The asynchronous Maybe to project.
selectorFunc<TIn, TOut>The projection function applied to the value.
Returns
- Task<Maybe<TOut>>
A task producing a Maybe with the projected value, or
Noneif the input has no value.
Type Parameters
TInThe type of the input value.
TOutThe type of the output value.
Where<TSource>(Task<Maybe<TSource>>, Func<TSource, bool>)
Filters an awaited Maybe<T> by a synchronous predicate (LINQ Where over async).
public static Task<Maybe<TSource>> Where<TSource>(this Task<Maybe<TSource>> source, Func<TSource, bool> predicate) where TSource : notnull
Parameters
sourceTask<Maybe<TSource>>The asynchronous Maybe to filter.
predicateFunc<TSource, bool>The predicate to test the value.
Returns
- Task<Maybe<TSource>>
The original Maybe when the predicate is true; otherwise
None.Noneinputs stayNone.
Type Parameters
TSourceType of the source value.