Table of Contents

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

source Task<Result<TSource>>

The asynchronous source result.

collectionSelector Func<TSource, Task<Result<TCollection>>>

An async function returning the intermediate result.

resultSelector Func<TSource, TCollection, TResult>

A synchronous function combining the source and intermediate values.

Returns

Task<Result<TResult>>

A task producing the combined result, or the first failure encountered.

Type Parameters

TSource

Type of the source value.

TCollection

Type of the intermediate collection value.

TResult

Type 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

resultTask Task<Result<TIn>>

The asynchronous result to project.

selector Func<TIn, TOut>

The projection function applied to the success value.

Returns

Task<Result<TOut>>

A task producing a result with the projected value, or the original failure.

Type Parameters

TIn

The type of the input value.

TOut

The 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

source Task<Result<TSource>>

The asynchronous result to filter.

predicate Func<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

TSource

Type of the source value.

Remarks

For meaningful error messages, prefer EnsureExtensionsAsync directly.