This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var client = new DocumentClient(new Uri(_endpoint), _key)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var link = UriFactory.CreateDocumentCollectionUri(_databaseId, CollectionId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var query = client.CreateDocumentQuery<Note>( | |
| link, | |
| new FeedOptions() | |
| { | |
| EnableCrossPartitionQuery = true | |
| }) | |
| .AsDocumentQuery(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var results = new List<Note>(); | |
| while (query.HasMoreResults) | |
| { | |
| results.AddRange(await query.ExecuteNextAsync<Note>()); | |
| } | |
| return results.OrderBy(x => x.Id).ToArray(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task<Note> Create(Note note) | |
| { | |
| using (var client = new DocumentClient(new Uri(_endpoint), _key)) | |
| { | |
| var link = UriFactory.CreateDocumentCollectionUri(_databaseId, CollectionId); | |
| await client.CreateDocumentAsync(link, note); | |
| return note; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task<Note> Update(Note note) | |
| { | |
| using (var client = new DocumentClient(new Uri(_endpoint), _key)) | |
| { | |
| var link = UriFactory.CreateDocumentUri(_databaseId, CollectionId, note.Id); | |
| await client.ReplaceDocumentAsync(link, note); | |
| return note; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task Delete(string id, string customerId) | |
| { | |
| using (var client = new DocumentClient(new Uri(_endpoint), _key)) | |
| { | |
| var link = UriFactory.CreateDocumentUri(_databaseId, CollectionId, id); | |
| await client.DeleteDocumentAsync(link, new RequestOptions() | |
| { PartitionKey = new Microsoft.Azure.Documents.PartitionKey(customerId)}); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NotesAccessor | |
| { | |
| const string CollectionId = "notes"; | |
| private string _endpoint; | |
| private string _key; | |
| private string _databaseId; | |
| public NotesAccessor(string endpoint, string key, string databaseId) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var endpoint = args[0]; | |
| var key = args[1]; | |
| var databaseId = args[2]; | |
| Task.Run(async () => | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dotnet new sln |