public override IAsyncEnumerable <Object> Execute(Object dataContext, OeQueryContext queryContext)
        {
            Expression           expression;
            MethodCallExpression countExpression = null;
            IQueryable           query           = queryContext.EntitySetAdapter.GetEntitySet(dataContext);

            if (base.QueryCache.AllowCache)
            {
                expression = GetFromCache(queryContext, (T)dataContext, base.QueryCache, out countExpression);
            }
            else
            {
                expression = queryContext.CreateExpression(new OeConstantToVariableVisitor());
                expression = new OeEf6EnumerableToQuerableVisitor().Visit(expression);
                expression = queryContext.TranslateSource(dataContext, expression);

                if (queryContext.IsQueryCount())
                {
                    countExpression = queryContext.CreateCountExpression(expression);
                }
            }

            IDbAsyncEnumerable        asyncEnumerable = (IDbAsyncEnumerable)query.Provider.CreateQuery(expression);
            IAsyncEnumerable <Object> asyncEnumerator = new OeEf6AsyncEnumerator(asyncEnumerable);

            if (countExpression != null)
            {
                query = queryContext.EntitySetAdapter.GetEntitySet(dataContext);
                queryContext.TotalCountOfItems = query.Provider.Execute <int>(countExpression);
            }

            return(asyncEnumerator);
        }
Esempio n. 2
0
        public override Db.OeAsyncEnumerator ExecuteEnumerator(Object dataContext, OeQueryContext queryContext, CancellationToken cancellationToken)
        {
            Expression           expression;
            MethodCallExpression countExpression = null;
            IQueryable           query           = queryContext.EntitySetAdapter.GetEntitySet(dataContext);

            if (base.QueryCache.AllowCache)
            {
                expression = GetFromCache(queryContext, (T)dataContext, base.QueryCache, out countExpression);
            }
            else
            {
                expression = queryContext.CreateExpression(new OeConstantToVariableVisitor());
                expression = new EnumerableToQuerableVisitor().Visit(expression);
                expression = queryContext.TranslateSource(dataContext, expression);

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

            IDbAsyncEnumerable asyncEnumerable = (IDbAsyncEnumerable)query.Provider.CreateQuery(expression);

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

            return(base.OperationAdapter.ApplyBoundFunction(asyncEnumerator, queryContext));
        }
Esempio n. 3
0
        public override Db.OeAsyncEnumerator ExecuteEnumerator(Object dataContext, OeQueryContext queryContext, CancellationToken cancellationToken)
        {
            IQueryable query      = queryContext.EntitySetAdapter.GetEntitySet(dataContext);
            Expression expression = queryContext.CreateExpression(query, new OeConstantToVariableVisitor(queryContext.SkipTokenParser != null));

            expression = new EnumerableToQuerableVisitor().Visit(expression);
            var queryAsync = (IDbAsyncEnumerable)query.Provider.CreateQuery(expression);

            Db.OeAsyncEnumerator asyncEnumerator = new OeEf6AsyncEnumerator(queryAsync.GetAsyncEnumerator(), cancellationToken);
            if (queryContext.CountExpression != null)
            {
                asyncEnumerator.Count = query.Provider.Execute <int>(queryContext.CountExpression);
            }

            return(asyncEnumerator);
        }