/// <summary>
 /// Asynchronously creates a <see cref="T:System.Collections.Generic.List`1" />
 /// from an <see cref="T:System.Linq.IQueryable`1" /> by enumerating it asynchronously.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <List <TSource> > ToListAsync <TSource>(
     this IProviderObservable <IQueryable <TSource> > observable) =>
 observable.MapAsync(async s => await s.ToListAsync());
Пример #2
0
 /// <summary>
 /// Emits the first element of a sequence, or a default
 /// value if the sequence contains no elements.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> FirstOrDefaultAsync <TSource>(
     this IProviderObservable <IQueryable <TSource> > observable) =>
 observable.MapAsync(async s => await s.FirstOrDefaultAsync());
Пример #3
0
 /// <summary>
 /// Emits the first element of a sequence that satisfies a specified condition.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="predicate">A function to test each element for a condition.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> FirstAsync <TSource>(
     this IProviderObservable <IQueryable <TSource> > observable,
     Expression <Func <TSource, bool> > predicate) =>
 observable.MapAsync(async s => await s.FirstAsync(predicate));
Пример #4
0
 /// <summary>
 /// Emits the only element of a sequence, and throws an exception
 /// if there is not exactly one element in the sequence.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> SingleAsync <TSource>(
     this IProviderObservable <IQueryable <TSource> > observable) =>
 observable.MapAsync(async s => await s.SingleAsync());