Example #1
0
        public Task <IReadOnlyCollection <IndexDocumentChange> > GetNextBatch()
        {
            IReadOnlyCollection <IndexDocumentChange> result = null;

            if (Skip < TotalCount)
            {
                var changes = DocumentIds
                              .Skip((int)Skip)
                              .Take((int)Take)
                              .Select(x => new IndexDocumentChange
                {
                    DocumentId = x,
                    ChangeDate = DateTime.UtcNow,
                    ChangeType = ChangeType
                })
                              .ToList();

                if (changes.Any())
                {
                    result = new ReadOnlyCollection <IndexDocumentChange>(changes);
                    Skip  += changes.Count;
                }
            }

            return(Task.FromResult(result));
        }
        public Task <IReadOnlyCollection <IndexDocumentChange> > GetNextBatch()
        {
            if (Skip >= TotalCount)
            {
                return(Task.FromResult <IReadOnlyCollection <IndexDocumentChange> >(null));
            }

            var changes = DocumentIds
                          .Skip((int)Skip)
                          .Take((int)Take)
                          .Select(x => new IndexDocumentChange
            {
                DocumentId = x,
                ChangeDate = DateTime.UtcNow,
                ChangeType = ChangeType
            })
                          .ToList();

            Skip += changes.Count;

            return(Task.FromResult((IReadOnlyCollection <IndexDocumentChange>)
                                   new ReadOnlyCollection <IndexDocumentChange>(changes)));
        }