コード例 #1
0
        public Task <CategorySummaries> ListCategoriesAsync(string userId)
        {
            var list = CategoryDocuments
                       .Where(d => d.UserId == userId)
                       .Select(d => new CategorySummary {
                Id = d.Id, Name = d.Name
            })
                       .ToList();
            var categorySummaries = new CategorySummaries();

            categorySummaries.AddRange(list);
            return(Task.FromResult(categorySummaries));
        }
コード例 #2
0
        public async Task <CategorySummaries> ListCategoriesAsync(string userId)
        {
            var documentUri = UriFactory.CreateDocumentCollectionUri(DatabaseName, CollectionName);

            // create a query to just get the document ids
            var query = DocumentClient
                        .CreateDocumentQuery <CategoryDocument>(documentUri)
                        .Where(d => d.UserId == userId)
                        .Select(d => new CategorySummary {
                Id = d.Id, Name = d.Name
            })
                        .AsDocumentQuery();

            // iterate until we have all of the ids
            var list = new CategorySummaries();

            while (query.HasMoreResults)
            {
                var summaries = await query.ExecuteNextAsync <CategorySummary>();

                list.AddRange(summaries);
            }
            return(list);
        }