public async Task WriteAsync(OeEntryFactory entryFactory, IAsyncEnumerator <Object> asyncEnumerator) { var resourceSet = new ODataResourceSet() { Count = _queryContext.TotalCountOfItems }; await _writer.WriteStartAsync(resourceSet).ConfigureAwait(false); Object?rawValue = null; int readCount = 0; Db.IOeDbEnumerator dbEnumerator = entryFactory.IsTuple ? (Db.IOeDbEnumerator) new Db.OeDbEnumerator(asyncEnumerator, entryFactory) : new Db.OeEntityDbEnumerator(asyncEnumerator, entryFactory); while (await dbEnumerator.MoveNextAsync().ConfigureAwait(false)) { await WriteEntry(dbEnumerator, dbEnumerator.Current).ConfigureAwait(false); readCount++; rawValue = dbEnumerator.RawValue; dbEnumerator.ClearBuffer(); } if (rawValue != null) { var nextPageLinkBuilder = new OeNextPageLinkBuilder(_queryContext); resourceSet.NextPageLink = nextPageLinkBuilder.GetNextPageLinkRoot(entryFactory, readCount, _queryContext.TotalCountOfItems, rawValue); } await _writer.WriteEndAsync().ConfigureAwait(false); }
private async Task WriteLazyNestedCollection(Db.IOeDbEnumerator dbEnumerator) { _writer.WriteStart(new ODataResourceSet()); do { Object value = dbEnumerator.Current; if (value != null) { await WriteEntry(dbEnumerator, value, false).ConfigureAwait(false); } }while (await dbEnumerator.MoveNextAsync().ConfigureAwait(false)); _writer.WriteEnd(); }
private async Task WriteNavigationCollection(Db.IOeDbEnumerator dbEnumerator) { var entryFactory = (OeNavigationEntryFactory)dbEnumerator.EntryFactory; Object value; int readCount = 0; ODataResourceSet?resourceSet = null; do { value = dbEnumerator.Current; if (value != null) { if (resourceSet == null) { resourceSet = new ODataResourceSet(); if (entryFactory.NavigationSelectItem.CountOption.GetValueOrDefault()) { resourceSet.Count = OeNextPageLinkBuilder.GetNestedCount(_queryContext.EdmModel, dbEnumerator); } await _writer.WriteStartAsync(resourceSet).ConfigureAwait(false); } await WriteEntry(dbEnumerator, value).ConfigureAwait(false); readCount++; } }while (await dbEnumerator.MoveNextAsync().ConfigureAwait(false)); if (resourceSet == null) { resourceSet = new ODataResourceSet(); if (entryFactory.NavigationSelectItem.CountOption.GetValueOrDefault()) { resourceSet.Count = 0; } await _writer.WriteStartAsync(resourceSet).ConfigureAwait(false); } else { var nextPageLinkBuilder = new OeNextPageLinkBuilder(_queryContext); resourceSet.NextPageLink = nextPageLinkBuilder.GetNextPageLinkNavigation(dbEnumerator, readCount, resourceSet.Count, value !); } await _writer.WriteEndAsync().ConfigureAwait(false); }
private async Task WriteEagerNestedCollection(Db.IOeDbEnumerator dbEnumerator) { var items = new List <Object>(); do { Object value = dbEnumerator.Current; if (value != null) { items.Add(value); } }while (await dbEnumerator.MoveNextAsync().ConfigureAwait(false)); _writer.WriteStart(new ODataResourceSet() { Count = items.Count }); for (int i = 0; i < items.Count; i++) { await WriteEntry(dbEnumerator, items[i], false).ConfigureAwait(false); } _writer.WriteEnd(); }