private async Task<int> IterateEntriesAsync(
     string collection, string commandText, 
     Func<string, IDictionary<string, object>, Task> func)
 {
     var result = 0;
     var entryKey = ExtractKeyFromCommandText(collection, commandText);
     if (entryKey != null)
     {
         await func(collection, entryKey);
         result = 1;
     }
     else
     {
         var client = new ODataClient(_settings);
         var entries = await client.FindEntriesAsync(commandText);
         if (entries != null)
         {
             var entryList = entries.ToList();
             foreach (var entry in entryList)
             {
                 await func(collection, entry);
                 ++result;
             }
         }
     }
     return result;
 }
Exemple #2
0
        private async Task <int> IterateEntriesAsync(ResolvedCommand command,
                                                     Func <string, IDictionary <string, object>, Task> funcAsync, CancellationToken cancellationToken)
        {
            var collectionName = command.QualifiedEntityCollectionName;

            var result  = 0;
            var client  = new ODataClient(_settings);
            var entries = await client.FindEntriesAsync(command.Format(), cancellationToken).ConfigureAwait(false);

            if (entries != null)
            {
                var entryList = entries.ToList();
                foreach (var entry in entryList)
                {
                    await funcAsync(collectionName, entry).ConfigureAwait(false);

                    if (cancellationToken.IsCancellationRequested)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                    }
                    ++result;
                }
            }
            return(result);
        }
        private async Task<IEnumerable<IDictionary<string, object>>> IterateEntriesAsync(
            string collection, string commandText, IDictionary<string, object> entryData, bool resultRequired,
            Func<string, IDictionary<string, object>, IDictionary<string, object>, bool, Task<IDictionary<string, object>>> func)
        {
            IEnumerable<IDictionary<string, object>> result = null;

            var entryKey = ExtractKeyFromCommandText(collection, commandText);
            if (entryKey != null)
            {
                result = new [] { await func(collection, entryKey, entryData, resultRequired) };
            }
            else
            {
                var client = new ODataClient(_settings);
                var entries = await client.FindEntriesAsync(commandText);
                if (entries != null)
                {
                    var entryList = entries.ToList();
                    var resultList = new List<IDictionary<string, object>>();
                    foreach (var entry in entryList)
                    {
                        resultList.Add(await func(collection, entry, entryData, resultRequired));
                    }
                    result = resultList;
                }
            }

            return result;
        }
Exemple #4
0
        private async Task <IEnumerable <IDictionary <string, object> > > IterateEntriesAsync(
            ResolvedCommand command, bool resultRequired,
            Func <string, IDictionary <string, object>, IDictionary <string, object>, bool, Task <IDictionary <string, object> > > funcAsync, CancellationToken cancellationToken)
        {
            var collectionName = command.QualifiedEntityCollectionName;
            var entryData      = command.CommandData;

            IEnumerable <IDictionary <string, object> > result = null;
            var client  = new ODataClient(_settings);
            var entries = await client.FindEntriesAsync(command.Format(), cancellationToken).ConfigureAwait(false);

            if (entries != null)
            {
                var entryList  = entries.ToList();
                var resultList = new List <IDictionary <string, object> >();
                foreach (var entry in entryList)
                {
                    resultList.Add(await funcAsync(collectionName, entry, entryData, resultRequired).ConfigureAwait(false));
                    if (cancellationToken.IsCancellationRequested)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                    }
                }
                result = resultList;
            }

            return(result);
        }