From 6f024d2b346304547b1d3b603a74a9be83749de1 Mon Sep 17 00:00:00 2001 From: Kasam Shaikh Date: Tue, 18 Dec 2018 21:52:27 +0530 Subject: [PATCH] Update DocumentDBRepository.cs Modified code to resolve runtime error, "PartitionKey value must be supplied for this operation." on Edit, Details, and Delete functionality. The error is now resolved and working fine as expected. --- src/DocumentDBRepository.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/DocumentDBRepository.cs b/src/DocumentDBRepository.cs index 23bbd61..fa20c53 100644 --- a/src/DocumentDBRepository.cs +++ b/src/DocumentDBRepository.cs @@ -23,7 +23,8 @@ public static async Task GetItemAsync(string id, string category) try { Document document = - await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id)); + await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id), + new RequestOptions { PartitionKey = new PartitionKey(category) }); return (T)(dynamic)document; } catch (DocumentClientException e) @@ -68,7 +69,8 @@ public static async Task UpdateItemAsync(string id, T item) public static async Task DeleteItemAsync(string id, string category) { - await client.DeleteDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id)); + await client.DeleteDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id), + new RequestOptions { PartitionKey = new PartitionKey(category) }); } public static void Initialize()