public async ValueTask <bool> MoveNextAsync() { if (_isFirstMoveNext) { _isFirstMoveNext = false; _isMoveNext = await _dbEnumerator.MoveNextAsync().ConfigureAwait(false); } if (!_isMoveNext) { return(false); } Dictionary <String, Object?>?entity = null; if (_dbEnumerator.Current != null) { entity = await CreateEntity(_dbEnumerator, _dbEnumerator.Current, _dbEnumerator.Current, _cancellationToken).ConfigureAwait(false); } _dbEnumerator.ClearBuffer(); _isMoveNext = await _dbEnumerator.MoveNextAsync().ConfigureAwait(false); Current = entity; return(true); }
public async Task <bool> MoveNext(CancellationToken cancellationToken) { if (_isFirstMoveNext) { _isFirstMoveNext = false; _isMoveNext = await _dbEnumerator.MoveNextAsync().ConfigureAwait(false); } if (!_isMoveNext) { return(false); } Dictionary <String, Object> entity = await CreateEntity(_dbEnumerator, _dbEnumerator.Current, _dbEnumerator.Current).ConfigureAwait(false); Object buffer = _dbEnumerator.ClearBuffer(); _isMoveNext = await _dbEnumerator.MoveNextAsync().ConfigureAwait(false); if (!_isMoveNext && _queryContext.SkipTokenNameValues != null && _queryContext.SkipTokenAccessors != null) { SetOrderByProperties(_queryContext, entity, buffer); } Current = entity; return(true); }
private static async Task <Object> CreateNestedEntity(Db.OeDbEnumerator dbEnumerator, Object value) { Object entity = dbEnumerator.Current; if (entity == null) { return(null); } if (dbEnumerator.EntryFactory.ResourceInfo.IsCollection.GetValueOrDefault()) { var entityList = new List <Object>(); do { Object item = dbEnumerator.Current; if (item != null) { entityList.Add(await CreateEntity(dbEnumerator, item, item).ConfigureAwait(false)); } }while (await dbEnumerator.MoveNextAsync().ConfigureAwait(false)); return(entityList); } return(await CreateEntity(dbEnumerator, value, entity).ConfigureAwait(false)); }
private static async Task <Object> CreateNestedEntity(Db.OeDbEnumerator dbEnumerator, Object value, Type nestedEntityType) { Object entity = dbEnumerator.Current; if (entity == null) { return(null); } if (dbEnumerator.EntryFactory.ResourceInfo.IsCollection.GetValueOrDefault()) { Infrastructure.IGenericListWrapper listWrapper = Infrastructure.GenericListWrapper.Create(nestedEntityType); do { Object item = dbEnumerator.Current; if (item != null) { listWrapper.Add(await CreateEntity(dbEnumerator, item, item, nestedEntityType).ConfigureAwait(false)); } }while (await dbEnumerator.MoveNextAsync().ConfigureAwait(false)); return(listWrapper.List); } return(await CreateEntity(dbEnumerator, value, entity, nestedEntityType).ConfigureAwait(false)); }
private static async Task <Object?> CreateNestedEntity(Db.OeDbEnumerator dbEnumerator, Object value, CancellationToken cancellationToken) { Object entity = dbEnumerator.Current; if (entity == null) { return(null); } var entryFactory = (OeNavigationEntryFactory)dbEnumerator.EntryFactory; if (entryFactory.EdmNavigationProperty.Type.Definition is EdmCollectionType) { var entityList = new List <Object>(); do { Object item = dbEnumerator.Current; if (item != null) { entityList.Add(await CreateEntity(dbEnumerator, item, item, cancellationToken).ConfigureAwait(false)); } }while (await dbEnumerator.MoveNextAsync().ConfigureAwait(false)); return(entityList); } return(await CreateEntity(dbEnumerator, value, entity, cancellationToken).ConfigureAwait(false)); }
public async Task SerializeAsync(OeEntryFactory entryFactory, Db.OeAsyncEnumerator asyncEnumerator, OeQueryContext queryContext) { var resourceSet = new ODataResourceSet() { Count = asyncEnumerator.Count }; _writer.WriteStart(resourceSet); Object buffer = null; int count = 0; var dbEnumerator = new Db.OeDbEnumerator(asyncEnumerator, entryFactory); while (await dbEnumerator.MoveNextAsync().ConfigureAwait(false)) { Object value = dbEnumerator.Current; await WriteEntry(dbEnumerator, value, _queryContext.NavigationNextLink).ConfigureAwait(false); count++; buffer = dbEnumerator.ClearBuffer(); } if (queryContext.PageSize > 0 && count > 0 && (asyncEnumerator.Count ?? Int32.MaxValue) > count) { resourceSet.NextPageLink = BuildNextPageLink(queryContext, buffer); } _writer.WriteEnd(); }
private async Task WriteLazyNestedCollection(Db.OeDbEnumerator 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 WriteEagerNestedCollection(Db.OeDbEnumerator 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(); }