Esempio n. 1
0
        private async Task SerializeAsync(ODataWriter writer)
        {
            var resourceSet = new ODataResourceSet()
            {
                Count = Count
            };

            writer.WriteStart(resourceSet);

            int count  = 0;
            T   entity = default;
            EntityPropertiesInfo entityPropertiesInfo = default;

            while (await _entities.MoveNext())
            {
                entity = _entities.Current;
                _stack.Add(entity);
                WriteEntry(writer, entity, ref entityPropertiesInfo);
                _stack.Remove(entity);
                count++;
            }

            if (PageSize > 0 && count > 0 && (Count ?? Int32.MaxValue) > count)
            {
                resourceSet.NextPageLink = BuildNextPageLink(OeSkipTokenParser.GetSkipToken(_edmModel, GetKeys(entity)));
            }

            writer.WriteEnd();
        }
        public Uri GetNextPageLinkRoot(OeEntryFactory entryFactory, int readCount, int?totalCount, Object value)
        {
            if (readCount == 0)
            {
                return(null);
            }

            int pageSize = GetPageSizeRoot();

            if (pageSize == 0)
            {
                return(null);
            }

            int restCount = GetRestCountRoot(readCount, totalCount);

            if (restCount == 0)
            {
                return(null);
            }

            ODataUri nextOdataUri = _queryContext.ODataUri.Clone();

            nextOdataUri.SelectAndExpand = _queryContext.ODataUri.SelectAndExpand;
            nextOdataUri.ServiceRoot     = null;
            nextOdataUri.QueryCount      = null;
            nextOdataUri.Top             = pageSize;
            nextOdataUri.Skip            = null;
            nextOdataUri.SkipToken       = OeSkipTokenParser.GetSkipToken(_queryContext.EdmModel, entryFactory.SkipTokenAccessors, value, restCount);

            return(nextOdataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses));
        }
Esempio n. 3
0
        private async Task SerializeAsync(ODataWriter writer, OeMetadataLevel metadataLevel)
        {
            ClrPropertiesInfo clrPropertiesInfo = GetClrPropertiesInfo(_edmModel, _odataUri.SelectAndExpand, metadataLevel, typeof(T), null);

            var resourceSet = new ODataResourceSet()
            {
                Count = Count
            };

            writer.WriteStart(resourceSet);

            int count  = 0;
            T   entity = default;

            while (await _entities.MoveNext())
            {
                entity = _entities.Current;
                _stack.Add(entity);
                WriteEntry(writer, entity, clrPropertiesInfo);
                _stack.Remove(entity);
                count++;
            }

            if (PageSize > 0 && count > 0 && (Count ?? Int32.MaxValue) > count)
            {
                resourceSet.NextPageLink = BuildNextPageLink(OeSkipTokenParser.GetSkipToken(_edmModel, GetKeys(entity)));
            }

            writer.WriteEnd();
        }
Esempio n. 4
0
            private static Uri BuildNextPageLink(OeQueryContext queryContext, Object value)
            {
                ODataUri nextOdataUri = queryContext.ODataUri.Clone();

                nextOdataUri.ServiceRoot = null;
                nextOdataUri.QueryCount  = null;
                nextOdataUri.Top         = queryContext.PageSize;
                nextOdataUri.Skip        = null;
                nextOdataUri.SkipToken   = OeSkipTokenParser.GetSkipToken(queryContext.EdmModel, queryContext.SkipTokenAccessors, value);

                return(nextOdataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses));
            }
        public Uri GetNextPageLinkNavigation(Db.IOeDbEnumerator dbEnumerator, int readCount, long?totalCount, Object value)
        {
            OeEntryFactory entryFactory = dbEnumerator.EntryFactory;
            ExpandedNavigationSelectItem navigationSelectItem = entryFactory.NavigationSelectItem;

            if (navigationSelectItem.GetPageSize() == 0 || readCount == 0 || (totalCount != null && readCount >= totalCount))
            {
                return(null);
            }

            OrderByClause orderByClause = OeSkipTokenParser.GetUniqueOrderBy(entryFactory.EntitySet, navigationSelectItem.OrderByOption, null);

            KeyValuePair <String, Object>[] keys = GetNavigationSkipTokenKeys(entryFactory, orderByClause, value);

            int    restCount = GetRestCountNavigation((int?)navigationSelectItem.TopOption, readCount, totalCount);
            String skipToken = OeSkipTokenParser.GetSkipToken(_queryContext.EdmModel, keys, restCount);

            return(GetNavigationUri(dbEnumerator.ParentEnumerator.EntryFactory, navigationSelectItem, orderByClause, dbEnumerator.ParentEnumerator.Current, skipToken));
        }