Exemplo n.º 1
0
        public override Db.OeAsyncEnumerator ExecuteEnumerator(Object dataContext, OeQueryContext queryContext, CancellationToken cancellationToken)
        {
            IAsyncEnumerable <Object> asyncEnumerable;
            MethodCallExpression      countExpression = null;

            if (base.QueryCache.AllowCache)
            {
                asyncEnumerable = GetFromCache <Object>(queryContext, (T)dataContext, base.QueryCache, out countExpression);
            }
            else
            {
                Expression expression = queryContext.CreateExpression(new OeConstantToVariableVisitor());
                IQueryable entitySet  = queryContext.EntitySetAdapter.GetEntitySet(dataContext);
                IQueryable query      = entitySet.Provider.CreateQuery(queryContext.TranslateSource(dataContext, expression));
                asyncEnumerable = ((IQueryable <Object>)query).AsAsyncEnumerable();

                if (queryContext.ODataUri.QueryCount.GetValueOrDefault())
                {
                    countExpression = OeQueryContext.CreateCountExpression(query.Expression);
                }
            }

            Db.OeAsyncEnumerator asyncEnumerator = new OeEfCoreAsyncEnumerator(asyncEnumerable.GetEnumerator(), cancellationToken);
            if (countExpression != null)
            {
                IQueryable query = queryContext.EntitySetAdapter.GetEntitySet(dataContext);
                asyncEnumerator.Count = query.Provider.Execute <int>(countExpression);
            }

            return(asyncEnumerator);
        }
Exemplo n.º 2
0
        public override Db.OeAsyncEnumerator ExecuteEnumerator(Object dataContext, OeQueryContext queryContext, CancellationToken cancellationToken)
        {
            IAsyncEnumerable <Object> asyncEnumerable;

            if (base.QueryCache.AllowCache)
            {
                asyncEnumerable = GetFromCache <Object>(queryContext, (T)dataContext, base.QueryCache);
            }
            else
            {
                IQueryable query = CreateQuery(queryContext, dataContext, new OeConstantToVariableVisitor(queryContext.SkipTokenParser != null));
                asyncEnumerable = ((IQueryable <Object>)query).AsAsyncEnumerable();
            }

            Db.OeAsyncEnumerator asyncEnumerator = new OeEfCoreAsyncEnumerator(asyncEnumerable.GetEnumerator(), cancellationToken);
            if (queryContext.CountExpression != null)
            {
                IQueryable query = queryContext.EntitySetAdapter.GetEntitySet(dataContext);
                asyncEnumerator.Count = query.Provider.Execute <int>(queryContext.CountExpression);
            }

            return(asyncEnumerator);
        }