diff --git a/.gitignore b/.gitignore index 2709d90..58fe233 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,5 @@ Thumbs.db ehthumbs.db # Folder config file -Desktop.ini \ No newline at end of file +Desktop.ini +/.vs/config/applicationhost.config diff --git a/src/DocumentDBRepository.cs b/src/DocumentDBRepository.cs index 2f5ab3c..62b7c99 100644 --- a/src/DocumentDBRepository.cs +++ b/src/DocumentDBRepository.cs @@ -16,11 +16,15 @@ public static class DocumentDBRepository where T : class private static readonly string CollectionId = ConfigurationManager.AppSettings["collection"]; private static DocumentClient client; + public static async Task GetItemAsync(string id) { try { - Document document = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id)); + Document document = await client.ReadDocumentAsync( + UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id), + new RequestOptions { PartitionKey = new PartitionKey("personal") } + ); return (T)(dynamic)document; } catch (DocumentClientException e) @@ -40,7 +44,7 @@ public static async Task> GetItemsAsync(Expression> { IDocumentQuery query = client.CreateDocumentQuery( UriFactory.CreateDocumentCollectionUri(DatabaseId, CollectionId), - new FeedOptions { MaxItemCount = -1 }) + new FeedOptions { MaxItemCount = -1, EnableCrossPartitionQuery = true }) .Where(predicate) .AsDocumentQuery(); @@ -65,7 +69,10 @@ public static async Task UpdateItemAsync(string id, T item) public static async Task DeleteItemAsync(string id) { - await client.DeleteDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id)); + await client.DeleteDocumentAsync( + UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id), + new RequestOptions { PartitionKey = new PartitionKey("personal") } + ); } public static void Initialize() @@ -107,7 +114,7 @@ private static async Task CreateCollectionIfNotExistsAsync() await client.CreateDocumentCollectionAsync( UriFactory.CreateDatabaseUri(DatabaseId), new DocumentCollection { Id = CollectionId }, - new RequestOptions { OfferThroughput = 1000 }); + new RequestOptions { OfferThroughput = 400 }); } else { diff --git a/src/Models/Item.cs b/src/Models/Item.cs index 377a4cd..98a99cf 100644 --- a/src/Models/Item.cs +++ b/src/Models/Item.cs @@ -8,6 +8,9 @@ public class Item [JsonProperty(PropertyName = "id")] public string Id { get; set; } + [JsonProperty(PropertyName = "category")] + public string Category = "personal"; + [JsonProperty(PropertyName = "name")] public string Name { get; set; }