public static async Task <int> CountPlayersStreamingIn <TIGrain, TProperties>(string city, ITestOutputHelper output, int delayInMiliseconds = 0) where TIGrain : IPlayerGrain, IIndexableGrain where TProperties : PlayerProperties { if (delayInMiliseconds > 0) { //wait for one second await Task.Delay(delayInMiliseconds); } var taskCompletionSource = new TaskCompletionSource <int>(); Task <int> tsk = taskCompletionSource.Task; Action <int> responseHandler = taskCompletionSource.SetResult; IOrleansQueryable <TIGrain, TProperties> q = from player in GrainClient.GrainFactory.GetActiveGrains <TIGrain, TProperties>() where player.Location == city select player; int counter = 0; var _ = q.ObserveResults(new QueryResultStreamObserver <TIGrain>(async entry => { counter++; output.WriteLine("guid = {0}, location = {1}, primary key = {2}", entry, await entry.GetLocation(), entry.GetPrimaryKeyLong()); }, () => { responseHandler(counter); return(TaskDone.Done); })); int finalCount = await tsk; Assert.Equal(finalCount, await CountPlayersBlockingIn(q)); return(finalCount); }
public static IOrleansQueryable <TSource, TProperties> Take <TSource, TProperties>(this IOrleansQueryable <TSource, TProperties> source, int count) where TSource : IIndexableGrain => (IOrleansQueryable <TSource, TProperties>)Queryable.Take(source, count);
/// <summary> /// Projects each element of a sequence into a new form. /// </summary> public static IOrleansQueryable <TResult, TProperties> Select <TSource, TProperties, TResult>(this IOrleansQueryable <TSource, TProperties> source, Expression <Func <TProperties, int, TResult> > selector) where TSource : IIndexableGrain where TResult : IIndexableGrain => (IOrleansQueryable <TResult, TProperties>)Queryable.Select(source, selector);
/// <summary> /// Sorts(secondary) the elements of a sequence in descending order according to a key. /// </summary> public static IOrleansQueryable <TIGrain, TProperties> ThenByDescending <TIGrain, TProperties, TK>(this IOrleansQueryable <TIGrain, TProperties> source, Expression <Func <TProperties, TK> > keySelector) where TIGrain : IIndexableGrain => (IOrleansQueryable <TIGrain, TProperties>)Queryable.ThenByDescending(source, keySelector);
/// <summary> /// Sorts the elements of a sequence in descending order according to a key. /// </summary> public static IOrleansQueryable <TIGrain, TProperties> OrderByDescending <TIGrain, TProperties, TK>(this IOrleansQueryable <TIGrain, TProperties> source, Expression <Func <TProperties, TK> > keySelector, IComparer <TK> comparer) where TIGrain : IIndexableGrain => (IOrleansQueryable <TIGrain, TProperties>)Queryable.OrderByDescending(source, keySelector, comparer);
/// <summary> /// Sorts the elements of a sequence in ascending order according to a key. /// </summary> public static IOrleansQueryable <TIGrain, TProperties> OrderBy <TIGrain, TProperties, TK>(this IOrleansQueryable <TIGrain, TProperties> source, Expression <Func <TProperties, TK> > keySelector) where TIGrain : IIndexableGrain => (IOrleansQueryable <TIGrain, TProperties>)Queryable.OrderBy(source, keySelector);
/// <summary> /// Filters a sequence of values based on a predicate. /// </summary> public static IOrleansQueryable <TIGrain, TProperties> Where <TIGrain, TProperties>(this IOrleansQueryable <TIGrain, TProperties> source, Expression <Func <TProperties, int, bool> > predicate) where TIGrain : IIndexableGrain => (IOrleansQueryable <TIGrain, TProperties>)Queryable.Where(source, predicate);
/// <summary> /// Sorts(secondary) the elements of a sequence in ascending order according to a key. /// </summary> public static IOrleansQueryable <TIGrain, TProperties> ThenBy <TIGrain, TProperties, TK>(this IOrleansQueryable <TIGrain, TProperties> source, Expression <Func <TProperties, TK> > keySelector) where TIGrain : IIndexableGrain { return((IOrleansQueryable <TIGrain, TProperties>)Queryable.ThenBy(source, keySelector)); }
/// <summary> /// Sorts the elements of a sequence in descending order according to a key. /// </summary> public static IOrleansQueryable <TIGrain, TProperties> OrderByDescending <TIGrain, TProperties, TK>(this IOrleansQueryable <TIGrain, TProperties> source, Expression <Func <TProperties, TK> > keySelector) where TIGrain : IIndexableGrain { return((IOrleansQueryable <TIGrain, TProperties>)Queryable.OrderByDescending(source, keySelector)); }
/// <summary> /// Bypasses a specified number of elements in a sequence and then returns the remaining elements. /// </summary> /// Summary: public static IOrleansQueryable <TSource, TProperties> Skip <TSource, TProperties>(this IOrleansQueryable <TSource, TProperties> source, int count) where TSource : IIndexableGrain { return((IOrleansQueryable <TSource, TProperties>)Queryable.Skip(source, count)); }
private static async Task <int> CountPlayersBlockingIn <TIGrain, TProperties>(IOrleansQueryable <TIGrain, TProperties> q) where TIGrain : IPlayerGrain, IIndexableGrain where TProperties : PlayerProperties { IOrleansQueryResult <TIGrain> result = await q.GetResults(); return(result.Count()); }