Skip to content

Commit 30c003a

Browse files
committed
More fixes
1 parent 68a3a8d commit 30c003a

File tree

22 files changed

+1166
-97
lines changed

22 files changed

+1166
-97
lines changed

samples/code-samples/CollectionManagement/CollectionManagement.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</SccProvider>
2222
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2323
<TargetFrameworkProfile />
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<PlatformTarget>AnyCPU</PlatformTarget>

samples/code-samples/CollectionManagement/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ private static async Task GetAndChangeCollectionPerformance(DocumentCollection s
178178

179179
// Get the offer again after replace
180180
offer = client.CreateOfferQuery().Where(o => o.ResourceLink == simpleCollection.SelfLink).AsEnumerable().Single();
181+
OfferV2 offerV2 = (OfferV2)offer;
182+
Console.WriteLine(offerV2.Content.OfferThroughput);
181183

182184
Console.WriteLine("3. Found Offer \n{0}\n using collection's ResourceId {1}.\n", offer, simpleCollection.ResourceId);
183185
}

samples/code-samples/DatabaseManagement/DatabaseManagement.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</SccProvider>
2222
<TargetFrameworkProfile />
2323
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<PlatformTarget>AnyCPU</PlatformTarget>

samples/code-samples/DocumentManagement/DocumentManagement.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</SccProvider>
2222
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2323
<TargetFrameworkProfile />
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<PlatformTarget>AnyCPU</PlatformTarget>

samples/code-samples/DocumentManagement/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ 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(databaseId, collectionId, "POCO1"));
401+
Document readDoc = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, "POCO1"));
402402
Console.WriteLine("ETag of read document - {0}", readDoc.ETag);
403403

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

439439
//get a document
440-
var response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseId, collectionId, "POCO2"));
440+
var response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, "POCO2"));
441441
readDoc = response.Resource;
442442
Console.WriteLine("Read doc with StatusCode of {0}", response.StatusCode);
443443

@@ -448,14 +448,14 @@ private static async Task UseETags()
448448
Type = AccessConditionType.IfNoneMatch
449449
};
450450

451-
response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseId, collectionId, "POCO2"), new RequestOptions { AccessCondition = accessCondition });
451+
response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, "POCO2"), new RequestOptions { AccessCondition = accessCondition });
452452
Console.WriteLine("Read doc with StatusCode of {0}", response.StatusCode);
453453

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

458-
response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseId, collectionId, "POCO2"), new RequestOptions { AccessCondition = accessCondition });
458+
response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, "POCO2"), new RequestOptions { AccessCondition = accessCondition });
459459
Console.WriteLine("Read doc with StatusCode of {0}", response.StatusCode);
460460
}
461461
private static void Cleanup()

samples/code-samples/Geospatial/Geospatial.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</SccProvider>
2222
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2323
<TargetFrameworkProfile />
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<PlatformTarget>AnyCPU</PlatformTarget>

samples/code-samples/IndexManagement/IndexManagement.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</SccProvider>
2222
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2323
<TargetFrameworkProfile />
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<PlatformTarget>AnyCPU</PlatformTarget>

samples/code-samples/Queries/Program.cs

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,13 @@ private static void QueryAllDocuments(string collectionLink)
125125
var families =
126126
from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
127127
select f;
128-
129-
var families = query.ToList();
130-
Assert("Expected two families", families.Count == 2);
128+
129+
Assert("Expected two families", families.ToList().Count == 2);
131130

132131
// LINQ Lambda
133132
families = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions);
134133
Assert("Expected two families", families.ToList().Count == 2);
135-
134+
136135
// SQL
137136
families = client.CreateDocumentQuery<Family>(collectionLink, "SELECT * FROM Families", DefaultOptions);
138137
Assert("Expected two families", families.ToList().Count == 2);
@@ -214,8 +213,7 @@ from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
214213
.Where(f => f.Id == "AndersenFamily" || f.Address.City == "NY")
215214
.Select(f => new { Name = f.LastName, City = f.Address.City });
216215

217-
items = query.ToList();
218-
foreach (var item in items)
216+
foreach (var item in query)
219217
{
220218
Console.WriteLine("The {0} family live in {1}", item.Name, item.City);
221219
}
@@ -239,16 +237,15 @@ private static void QueryWithAndFilter(string collectionLink)
239237
where f.Id == "AndersenFamily" && f.Address.City == "Seattle"
240238
select f;
241239

242-
var families = query.ToList();
243-
Assert("Expected only 1 family", families.Count == 1);
240+
Assert("Expected only 1 family", families.ToList().Count == 1);
244241

245242
// LINQ Lambda -- Id == "value" AND City == "value"
246243
families = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
247244
.Where(f => f.Id == "AndersenFamily" && f.Address.City == "Seattle");
248245
Assert("Expected only 1 family", families.ToList().Count == 1);
249246

250247
// SQL -- Id == "value" AND City == "value"
251-
query = client.CreateDocumentQuery<Family>(
248+
families = client.CreateDocumentQuery<Family>(
252249
collectionLink,
253250
"SELECT * FROM Families f WHERE f.id='AndersenFamily' AND f.Address.City='Seattle'",
254251
DefaultOptions);
@@ -263,8 +260,7 @@ from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
263260
where f.Id == "AndersenFamily"
264261
select f;
265262

266-
var families = query.ToList();
267-
Assert("Expected only 1 family", families.Count == 1);
263+
Assert("Expected only 1 family", families.ToList().Count == 1);
268264

269265
// LINQ Lambda -- Id == "value"
270266
families = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions).Where(f => f.Id == "AndersenFamily");
@@ -282,31 +278,32 @@ private static void QueryWithInequality(string collectionLink)
282278
{
283279
// Simple query with a single property inequality comparison
284280
// LINQ Query
285-
var families = from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
281+
var query = from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
286282
where f.Id != "AndersenFamily"
287283
select f;
288284

289285
var families = query.ToList();
290286
Assert("Expected only 1 family", families.Count == 1);
291287

292288
// LINQ Lambda
293-
families = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
289+
query = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
294290
.Where(f => f.Id != "AndersenFamily");
295291

296292
families = query.ToList();
297293
Assert("Expected only 1 family", families.Count == 1);
298294

299295

300296
// SQL - in SQL you can use <> interchangably with != for "not equals"
301-
families = client.CreateDocumentQuery<Family>(
297+
query = client.CreateDocumentQuery<Family>(
302298
collectionLink,
303299
"SELECT * FROM Families f WHERE f.id <> 'AndersenFamily'",
304300
DefaultOptions);
305301

302+
families = query.ToList();
306303
Assert("Expected only 1 family", families.ToList().Count == 1);
307304

308305
//combine equality and inequality
309-
families =
306+
query =
310307
from f in client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
311308
where f.Id == "Wakefield" && f.Address.City != "NY"
312309
select f;
@@ -330,23 +327,20 @@ private static void QueryWithRangeOperatorsOnNumbers(string collectionLink)
330327
where f.Children[0].Grade > 5
331328
select f;
332329

333-
var families = query.ToList();
334-
Assert("Expected only 1 family", families.Count == 1);
330+
Assert("Expected only 1 family", families.ToList().Count == 1);
335331

336332
// LINQ Lambda
337333
families = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
338334
.Where(f => f.Children[0].Grade > 5);
339335

340-
families = query.ToList();
341-
Assert("Expected only 1 family", families.Count == 1);
336+
Assert("Expected only 1 family", families.ToList().Count == 1);
342337

343338
// SQL
344339
families = client.CreateDocumentQuery<Family>(collectionLink,
345340
"SELECT * FROM Families f WHERE f.Children[0].Grade > 5",
346341
DefaultOptions);
347342

348-
families = query.ToList();
349-
Assert("Expected only 1 family", families.Count == 1);
343+
Assert("Expected only 1 family", families.ToList().Count == 1);
350344
}
351345

352346

@@ -362,7 +356,7 @@ private static void QueryWithOrderBy(string collectionLink)
362356
private static void QueryWithRangeOperatorsOnStrings(string collectionLink)
363357
{
364358
// SQL Query (can't do this in LINQ)
365-
var query = client.CreateDocumentQuery<Family>(
359+
var families = client.CreateDocumentQuery<Family>(
366360
collectionLink,
367361
"SELECT * FROM Families f WHERE f.Address.State > 'NY'",
368362
new FeedOptions { EnableScanInQuery = true, EnableCrossPartitionQuery = true });
@@ -405,25 +399,22 @@ private static void QueryWithOrderByStrings(string collectionLink)
405399
orderby f.Address.State descending
406400
select f;
407401

408-
var families = query.ToList();
409-
Assert("Expected only 1 family", families.Count == 1);
402+
Assert("Expected only 1 family", familiesLinqQuery.ToList().Count == 1);
410403

411404
// LINQ Lambda
412405
familiesLinqQuery = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
413406
.Where(f => f.LastName == "Andersen")
414407
.OrderByDescending(f => f.Address.State);
415408

416-
families = query.ToList();
417-
Assert("Expected only 1 family", families.Count == 1);
409+
Assert("Expected only 1 family", familiesLinqQuery.ToList().Count == 1);
418410

419411
// SQL
420412
var familiesSqlQuery = client.CreateDocumentQuery<Family>(
421413
collectionLink,
422414
"SELECT * FROM Families f WHERE f.LastName = 'Andersen' ORDER BY f.Address.State DESC",
423415
DefaultOptions);
424416

425-
families = q.ToList();
426-
Assert("Expected only 1 family", families.Count == 1);
417+
Assert("Expected only 1 family", familiesSqlQuery.ToList().Count == 1);
427418
}
428419

429420
private static void QueryWithSubdocuments(string collectionLink)
@@ -438,8 +429,7 @@ private static void QueryWithSubdocuments(string collectionLink)
438429
"SELECT c FROM c IN f.Children",
439430
DefaultOptions).ToList();
440431

441-
var children = query.ToList();
442-
foreach (var child in children)
432+
foreach (var child in childrenSqlQuery)
443433
{
444434
Console.WriteLine(JsonConvert.SerializeObject(child));
445435
}
@@ -449,8 +439,7 @@ private static void QueryWithSubdocuments(string collectionLink)
449439
.SelectMany(family => family.Children
450440
.Select(c => c));
451441

452-
children = query.ToList();
453-
foreach (var child in children)
442+
foreach (var child in childrenLinqQuery)
454443
{
455444
Console.WriteLine(JsonConvert.SerializeObject(child));
456445
}
@@ -489,7 +478,7 @@ private static void QueryWithTwoJoinsAndFilter(string collectionLink)
489478
}
490479

491480
// LINQ
492-
familiesChildrenAndPets = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
481+
var familiesChildrenAndPets = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
493482
.SelectMany(family => family.Children
494483
.SelectMany(child => child.Pets
495484
.Where(pet => pet.GivenName == "Fluffy")
@@ -501,10 +490,9 @@ private static void QueryWithTwoJoinsAndFilter(string collectionLink)
501490
}
502491
)));
503492

504-
items = query.ToList();
505-
foreach (var item in items)
493+
foreach (var pet in familiesChildrenAndPets)
506494
{
507-
Console.WriteLine(item);
495+
Console.WriteLine(pet);
508496
}
509497
}
510498

@@ -519,8 +507,7 @@ private static void QueryWithTwoJoins(string collectionLink)
519507
"JOIN p IN c.Pets ",
520508
DefaultOptions);
521509

522-
var items = query.ToList();
523-
foreach (var item in items)
510+
foreach (var item in familiesChildrenAndPets)
524511
{
525512
Console.WriteLine(item);
526513
}
@@ -536,9 +523,8 @@ private static void QueryWithTwoJoins(string collectionLink)
536523
pet = pet.GivenName
537524
}
538525
)));
539-
540-
items = query.ToList();
541-
foreach (var item in items)
526+
527+
foreach (var item in familiesChildrenAndPets)
542528
{
543529
Console.WriteLine(item);
544530
}
@@ -553,19 +539,17 @@ private static void QueryWithSingleJoin(string collectionLink)
553539
"FROM Families f " +
554540
"JOIN c IN f.Children", DefaultOptions);
555541

556-
var items = query.ToList();
557-
foreach (var item in items)
542+
foreach (var item in query)
558543
{
559544
Console.WriteLine(JsonConvert.SerializeObject(item));
560545
}
561546

562547
// LINQ
563-
familiesAndChildren = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
548+
var familiesAndChildren = client.CreateDocumentQuery<Family>(collectionLink, DefaultOptions)
564549
.SelectMany(family => family.Children
565550
.Select(c => family.Id));
566551

567-
items = query.ToList();
568-
foreach (var item in items)
552+
foreach (var item in familiesAndChildren)
569553
{
570554
Console.WriteLine(JsonConvert.SerializeObject(item));
571555
}

samples/code-samples/Queries/Queries.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</SccProvider>
2222
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2323
<TargetFrameworkProfile />
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<PlatformTarget>AnyCPU</PlatformTarget>

samples/code-samples/ServerSideScripts/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ await client.CreateDocumentAsync(
363363
aggregateEntry = client.CreateDocumentQuery<dynamic>(
364364
collectionLink,
365365
"SELECT * FROM root r WHERE r.isMetadata = true",
366-
new FeedOptions { PartitionKey = new object[] { "Device001" } }).AsEnumerable().First();
366+
new FeedOptions { PartitionKey = new PartitionKeyValue("Device0001") }).AsEnumerable().First();
367367

368368
Console.WriteLine("Document statistics: min size: {0}, max size: {1}, total size: {2}",
369369
aggregateEntry.MinSize,

samples/code-samples/ServerSideScripts/ServerSideScripts.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</SccProvider>
2222
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2323
<TargetFrameworkProfile />
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<PlatformTarget>AnyCPU</PlatformTarget>

samples/code-samples/Shared/Shared.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</SccProvider>
2222
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2323
<TargetFrameworkProfile />
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<DebugSymbols>true</DebugSymbols>

samples/code-samples/Shared/Util/DocumentClientHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public static async Task<DocumentCollection> CreateDocumentCollectionWithRetries
209209
() => client.CreateDocumentCollectionAsync(
210210
UriFactory.CreateDatabaseUri(databaseId),
211211
collectionDefinition,
212-
new RequestOptions { OfferThroughput = (uint)offerThroughput }));
212+
new RequestOptions { OfferThroughput = offerThroughput }));
213213
}
214214

215215
/// <summary>

samples/code-samples/UserManagement/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private static async Task<Permission> CreatePermissionAsync(string resourceLink,
124124

125125
if (resourcePartitionKey != null)
126126
{
127-
permission.ResourcePartitionKey = new object[] { resourcePartitionKey };
127+
permission.ResourcePartitionKey = new PartitionKeyValue(resourcePartitionKey);
128128
}
129129

130130
ResourceResponse<Permission> response = await DocumentClientHelper.ExecuteWithRetries<ResourceResponse<Permission>>(

samples/code-samples/UserManagement/UserManagement.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
</SccProvider>
2222
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2323
<TargetFrameworkProfile />
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<PlatformTarget>AnyCPU</PlatformTarget>

0 commit comments

Comments
 (0)