public FdbSelectManyAsyncIterator([NotNull] IFdbAsyncEnumerable <TSource> source, AsyncTransformExpression <TSource, IEnumerable <TResult> > selector) : base(source) { // Must have at least one, but not both Contract.Requires(selector != null); m_selector = selector; }
internal static FdbWhereSelectAsyncIterator <TSource, TResult> Map <TSource, TResult>( [NotNull] IFdbAsyncEnumerable <TSource> source, [NotNull] AsyncTransformExpression <TSource, TResult> selector, int?limit = null, int? offset = null) { return(new FdbWhereSelectAsyncIterator <TSource, TResult>(source, filter: null, transform: selector, limit: limit, offset: offset)); }
internal static FdbSelectManyAsyncIterator <TSource, TCollection, TResult> Flatten <TSource, TCollection, TResult>( [NotNull] IFdbAsyncEnumerable <TSource> source, [NotNull] AsyncTransformExpression <TSource, IEnumerable <TCollection> > collectionSelector, [NotNull] Func <TSource, TCollection, TResult> resultSelector) { return(new FdbSelectManyAsyncIterator <TSource, TCollection, TResult>( source, collectionSelector, resultSelector )); }
public static AsyncTransformExpression <TSource, TOuter> Then <TOuter>([NotNull] AsyncTransformExpression <TSource, TResult> left, [NotNull] AsyncTransformExpression <TResult, TOuter> right) { if (left == null) { throw new ArgumentNullException("left"); } if (right == null) { throw new ArgumentNullException("right"); } if (left.IsIdentity()) { // we can optimize the left expression away, since we know that TSource == TResult ! //note: fool the compiler into believing that TSource == TResult return((AsyncTransformExpression <TSource, TOuter>)(object) right); } if (right.IsIdentity()) { // we can optimize the right expression away, since we know that TResult == TOuter ! return((AsyncTransformExpression <TSource, TOuter>)(object) left); } if (left.m_transform != null) { var f = left.m_transform; if (right.m_transform != null) { var g = right.m_transform; return(new AsyncTransformExpression <TSource, TOuter>((x) => g(f(x)))); } else { var g = right.m_asyncTransform; return(new AsyncTransformExpression <TSource, TOuter>((x, ct) => g(f(x), ct))); } } else { var f = left.m_asyncTransform; if (right.m_asyncTransform != null) { var g = right.m_asyncTransform; return(new AsyncTransformExpression <TSource, TOuter>(async(x, ct) => await g(await f(x, ct).ConfigureAwait(false), ct).ConfigureAwait(false))); } else { var g = right.m_transform; return(new AsyncTransformExpression <TSource, TOuter>(async(x, ct) => g(await f(x, ct).ConfigureAwait(false)))); } } }
public FdbWhereSelectAsyncIterator( [NotNull] IFdbAsyncEnumerable <TSource> source, AsyncFilterExpression <TSource> filter, AsyncTransformExpression <TSource, TResult> transform, int?limit, int?offset ) : base(source) { Contract.Requires(transform != null); // must do at least something Contract.Requires((limit ?? 0) >= 0 && (offset ?? 0) >= 0); // bounds cannot be negative m_filter = filter; m_transform = transform; m_limit = limit; m_offset = offset; }
internal static FdbSelectManyAsyncIterator <TSource, TResult> Flatten <TSource, TResult>( [NotNull] IFdbAsyncEnumerable <TSource> source, [NotNull] AsyncTransformExpression <TSource, IEnumerable <TResult> > selector) { return(new FdbSelectManyAsyncIterator <TSource, TResult>(source, selector)); }
public AsyncTransformExpression <TSource, TOuter> Then <TOuter>([NotNull] AsyncTransformExpression <TResult, TOuter> expr) { return(Then <TOuter>(this, expr)); }