Class ResultLinqExtensionsTaskAsync
- Namespace
- Trellis
- Assembly
- Trellis.Core.dll
Provides LINQ query expression support for Task<TResult> of Result<TValue>, enabling C# query syntax over fully asynchronous Result-returning operations.
public static class ResultLinqExtensionsTaskAsync
- Inheritance
-
ResultLinqExtensionsTaskAsync
- 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 GetAsync() compiles when
GetAsync() returns Task<Result<T>>, removing the need to await each
step and re-enter a sync query block.
The semantics mirror the synchronous ResultLinqExtensions overloads: failures short-circuit subsequent steps; only success values are passed to the next selector.
Methods
SelectMany<TSource, TCollection, TResult>(Task<Result<TSource>>, Func<TSource, Task<Result<TCollection>>>, Func<TSource, TCollection, TResult>)
Projects the value of an awaited Result<TValue> through an async collection selector
and combines the results (LINQ SelectMany over async/async).
public static Task<Result<TResult>> SelectMany<TSource, TCollection, TResult>(this Task<Result<TSource>> source, Func<TSource, Task<Result<TCollection>>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
Parameters
sourceTask<Result<TSource>>The asynchronous source result.
collectionSelectorFunc<TSource, Task<Result<TCollection>>>An async function returning the intermediate result.
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<Result<TIn>>, Func<TIn, TOut>)
Projects the value of a successful awaited Result<TValue> using a synchronous selector
(LINQ Select over Task<TResult>).
public static Task<Result<TOut>> Select<TIn, TOut>(this Task<Result<TIn>> resultTask, Func<TIn, TOut> selector)
Parameters
resultTaskTask<Result<TIn>>The asynchronous result to project.
selectorFunc<TIn, TOut>The projection function applied to the success value.
Returns
Type Parameters
TInThe type of the input value.
TOutThe type of the output value.
Where<TSource>(Task<Result<TSource>>, Func<TSource, bool>)
Filters an awaited Result<TValue> by a synchronous predicate (LINQ Where over async).
public static Task<Result<TSource>> Where<TSource>(this Task<Result<TSource>> source, Func<TSource, bool> predicate)
Parameters
sourceTask<Result<TSource>>The asynchronous result to filter.
predicateFunc<TSource, bool>The predicate to test the success value.
Returns
- Task<Result<TSource>>
The original success when the predicate is true; otherwise a generic "filtered out" failure.
Type Parameters
TSourceType of the source value.
Remarks
For meaningful error messages, prefer EnsureExtensionsAsync directly.