Beispiel #1
0
        /// <summary>Returns the first element of a sequence query</summary>
        public static Task <int> CountAsync <T>(this IFdbAsyncSequenceQueryable <T> query, CancellationToken ct = default(CancellationToken))
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var expr = FdbQueryExpressions.Single <T, int>(
                (FdbQuerySequenceExpression <T>)query.Expression,
                "CountAsync",
                (source, _ct) => source.CountAsync(_ct)
                );

            return(query.Provider.CreateQuery <int>(expr).ExecuteSingle(ct));
        }
Beispiel #2
0
        /// <summary>Returns the first element of a sequence query</summary>
        public static Task <T> FirstOrDefaultAsync <T>(this IFdbAsyncSequenceQueryable <T> query, CancellationToken ct = default(CancellationToken))
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (ct.IsCancellationRequested)
            {
                return(Task.FromCanceled <T>(ct));
            }

            var expr = FdbQueryExpressions.Single <T, T>(
                (FdbQuerySequenceExpression <T>)query.Expression,
                "FirstOrDefaultAsync",
                (source, _ct) => source.FirstOrDefaultAsync(_ct)
                );

            return(query.Provider.CreateQuery <T>(expr).ExecuteSingle(ct));
        }