Skip to content

Commit ec4aaac

Browse files
committed
Update for 1.6.1
1 parent 06dfba2 commit ec4aaac

23 files changed

+111
-76
lines changed

samples/code-samples/CollectionManagement/CollectionManagement.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<WarningLevel>4</WarningLevel>
4545
</PropertyGroup>
4646
<ItemGroup>
47-
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca, processorArchitecture=MSIL">
48-
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.0\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
47+
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
48+
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
4949
<Private>True</Private>
5050
</Reference>
5151
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -77,12 +77,12 @@
7777
<Folder Include="Properties\" />
7878
</ItemGroup>
7979
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
80-
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets')" />
80+
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" />
8181
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
8282
<PropertyGroup>
8383
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
8484
</PropertyGroup>
85-
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets'))" />
85+
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
8686
</Target>
8787
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
8888
Other similar extension points exist, see Microsoft.Common.targets.

samples/code-samples/CollectionManagement/Program.cs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,13 @@ public static void Main(string[] args)
6262
{
6363
using (client = new DocumentClient(new Uri(endpointUrl), authorizationKey, connectionPolicy))
6464
{
65-
CreateDatabaseIfNotExistsAsync().Wait();
65+
CreateNewDatabaseAsync().Wait();
6666
RunCollectionDemo().Wait();
6767
}
6868
}
69-
catch (DocumentClientException de)
70-
{
71-
Exception baseException = de.GetBaseException();
72-
Console.WriteLine("{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message);
73-
}
7469
catch (Exception e)
7570
{
76-
Exception baseException = e.GetBaseException();
77-
Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
71+
LogException(e);
7872
}
7973
finally
8074
{
@@ -87,12 +81,12 @@ public static void Main(string[] args)
8781
/// Create database if it does not exist
8882
/// </summary>
8983
/// <returns></returns>
90-
private static async Task CreateDatabaseIfNotExistsAsync()
84+
private static async Task CreateNewDatabaseAsync()
9185
{
9286
try
9387
{
9488
await client.ReadDatabaseAsync(UriFactory.CreateDatabaseUri(databaseName));
95-
return;
89+
await client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(databaseName));
9690
}
9791
catch (DocumentClientException e)
9892
{
@@ -137,12 +131,12 @@ private static async Task<DocumentCollection> CreateCollection()
137131
Console.WriteLine("\n1.1. Created Collection \n{0}", simpleCollection);
138132
return simpleCollection;
139133
}
134+
140135
private static async Task CreateCollectionWithCustomIndexingPolicy()
141136
{
142137
// Create a collection with custom index policy (lazy indexing)
143138
// We cover index policies in detail in IndexManagement sample project
144139
DocumentCollection collectionDefinition = new DocumentCollection();
145-
146140
collectionDefinition.Id = "SampleCollectionWithCustomIndexPolicy";
147141
collectionDefinition.IndexingPolicy.IndexingMode = IndexingMode.Lazy;
148142

@@ -173,7 +167,7 @@ private static async Task GetAndChangeCollectionPerformance(DocumentCollection s
173167
// Let's change the performance of the collection to 500 RU/s
174168
//******************************************************************************************************************
175169

176-
Offer replaced = await client.ReplaceOfferAsync(new OfferV2 { Content = new OfferContentV2(500) });
170+
Offer replaced = await client.ReplaceOfferAsync(new OfferV2(offer, 500));
177171
Console.WriteLine("\n3. Replaced Offer. Offer is now {0}.\n", replaced);
178172

179173
// Get the offer again after replace
@@ -218,5 +212,25 @@ private static async Task DeleteCollection()
218212
await client.DeleteDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName));
219213
Console.WriteLine("\n6. Deleted Collection\n");
220214
}
215+
216+
private static void LogException(Exception e)
217+
{
218+
ConsoleColor color = Console.ForegroundColor;
219+
Console.ForegroundColor = ConsoleColor.Red;
220+
221+
if (e is DocumentClientException)
222+
{
223+
DocumentClientException de = (DocumentClientException)e;
224+
Exception baseException = de.GetBaseException();
225+
Console.WriteLine("{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message);
226+
}
227+
else
228+
{
229+
Exception baseException = e.GetBaseException();
230+
Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
231+
}
232+
233+
Console.ForegroundColor = color;
234+
}
221235
}
222236
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Azure.DocumentDB" version="1.6.0" targetFramework="net451" />
3+
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
44
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
55
</packages>

samples/code-samples/DatabaseManagement/DatabaseManagement.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<WarningLevel>4</WarningLevel>
4545
</PropertyGroup>
4646
<ItemGroup>
47-
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca, processorArchitecture=MSIL">
48-
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.0\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
47+
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
48+
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
4949
<Private>True</Private>
5050
</Reference>
5151
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -79,12 +79,12 @@
7979
<Folder Include="Properties\" />
8080
</ItemGroup>
8181
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82-
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets')" />
82+
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" />
8383
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
8484
<PropertyGroup>
8585
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
8686
</PropertyGroup>
87-
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets'))" />
87+
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
8888
</Target>
8989
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
9090
Other similar extension points exist, see Microsoft.Common.targets.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Azure.DocumentDB" version="1.6.0" targetFramework="net451" />
3+
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
44
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
55
</packages>

samples/code-samples/DocumentManagement/DocumentManagement.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<WarningLevel>4</WarningLevel>
4545
</PropertyGroup>
4646
<ItemGroup>
47-
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca, processorArchitecture=MSIL">
48-
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.0\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
47+
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
48+
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
4949
<Private>True</Private>
5050
</Reference>
5151
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -82,12 +82,12 @@
8282
<Folder Include="Properties\" />
8383
</ItemGroup>
8484
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
85-
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets')" />
85+
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" />
8686
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
8787
<PropertyGroup>
8888
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
8989
</PropertyGroup>
90-
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets'))" />
90+
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
9191
</Target>
9292
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
9393
Other similar extension points exist, see Microsoft.Common.targets.

samples/code-samples/DocumentManagement/Program.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private static async Task ReadDocumentAsync()
161161
// partitioned i.e. does not have a partition key definition during creation.
162162
var response = await client.ReadDocumentAsync(
163163
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder1"),
164-
new RequestOptions { PartitionKey = new PartitionKeyValue("Account1") });
164+
new RequestOptions { PartitionKey = new PartitionKey("Account1") });
165165

166166
// You can measure the throughput consumed by any operation by inspecting the RequestCharge property
167167
Console.WriteLine("Document read by Id {0}", response.Resource);
@@ -257,7 +257,7 @@ private static async Task DeleteDocumentAsync()
257257
Console.WriteLine("\n1.7 - Deleting a document");
258258
ResourceResponse<Document> response = await client.DeleteDocumentAsync(
259259
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder3"),
260-
new RequestOptions { PartitionKey = new PartitionKeyValue("Account1") });
260+
new RequestOptions { PartitionKey = new PartitionKey("Account1") });
261261

262262
Console.WriteLine("Request charge of delete operation: {0}", response.RequestCharge);
263263
Console.WriteLine("StatusCode of operation: {0}", response.StatusCode);
@@ -349,7 +349,7 @@ private static async Task RunBasicOperationsOnDynamicObjects()
349349

350350
response = await client.ReadDocumentAsync(
351351
UriFactory.CreateDocumentUri(databaseName, collectionName, "_SalesOrder5"),
352-
new RequestOptions { PartitionKey = new PartitionKeyValue("NewUser01") });
352+
new RequestOptions { PartitionKey = new PartitionKey("NewUser01") });
353353

354354
var readDocument = response.Resource;
355355

@@ -398,7 +398,10 @@ private static async Task UseETags()
398398
Console.WriteLine("\n3.1 - Using optimistic concurrency when doing a ReplaceDocumentAsync");
399399

400400
//read a document
401-
Document readDoc = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, "POCO1"));
401+
Document readDoc = await client.ReadDocumentAsync(
402+
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder1"),
403+
new RequestOptions { PartitionKey = new PartitionKey("Account1") });
404+
402405
Console.WriteLine("ETag of read document - {0}", readDoc.ETag);
403406

404407
//take advantage of the dynamic nature of Document and set a new property on the document we just read
@@ -437,7 +440,10 @@ private static async Task UseETags()
437440
Console.WriteLine("\n3.2 - Using ETag to do a conditional ReadDocumentAsync");
438441

439442
//get a document
440-
var response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, "POCO2"));
443+
var response = await client.ReadDocumentAsync(
444+
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder2"),
445+
new RequestOptions { PartitionKey = new PartitionKey("Account2") });
446+
441447
readDoc = response.Resource;
442448
Console.WriteLine("Read doc with StatusCode of {0}", response.StatusCode);
443449

@@ -448,16 +454,31 @@ private static async Task UseETags()
448454
Type = AccessConditionType.IfNoneMatch
449455
};
450456

451-
response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, "POCO2"), new RequestOptions { AccessCondition = accessCondition });
457+
response = await client.ReadDocumentAsync(
458+
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder2"),
459+
new RequestOptions
460+
{
461+
AccessCondition = accessCondition,
462+
PartitionKey = new PartitionKey("Account2")
463+
});
464+
452465
Console.WriteLine("Read doc with StatusCode of {0}", response.StatusCode);
453466

454467
//now change something on the document, then do another get and this time we should get the document back
455468
readDoc.SetPropertyValue("foo", "updated");
456469
response = await client.ReplaceDocumentAsync(readDoc);
457470

458-
response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, "POCO2"), new RequestOptions { AccessCondition = accessCondition });
471+
response = await client.ReadDocumentAsync(
472+
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder2"),
473+
new RequestOptions
474+
{
475+
AccessCondition = accessCondition,
476+
PartitionKey = new PartitionKey("Account2")
477+
});
478+
459479
Console.WriteLine("Read doc with StatusCode of {0}", response.StatusCode);
460480
}
481+
461482
private static void Cleanup()
462483
{
463484
client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(databaseName)).Wait();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Azure.DocumentDB" version="1.6.0" targetFramework="net451" />
3+
<package id="Microsoft.Azure.DocumentDB" version="1.6.1" targetFramework="net451" />
44
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
55
</packages>

samples/code-samples/Geospatial/Geospatial.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<WarningLevel>4</WarningLevel>
4545
</PropertyGroup>
4646
<ItemGroup>
47-
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca, processorArchitecture=MSIL">
48-
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.0\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
47+
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
48+
<HintPath>..\packages\Microsoft.Azure.DocumentDB.1.6.1\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
4949
<Private>True</Private>
5050
</Reference>
5151
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -82,12 +82,12 @@
8282
</ProjectReference>
8383
</ItemGroup>
8484
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
85-
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets')" />
85+
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" />
8686
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
8787
<PropertyGroup>
8888
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
8989
</PropertyGroup>
90-
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.0\build\Microsoft.Azure.DocumentDB.targets'))" />
90+
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.1.6.1\build\Microsoft.Azure.DocumentDB.targets'))" />
9191
</Target>
9292
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
9393
Other similar extension points exist, see Microsoft.Common.targets.

0 commit comments

Comments
 (0)