Skip to content

Commit 4ee358c

Browse files
committed
Merge pull request Azure#63 from kspearrin/fixes
Fixes to various samples code
2 parents 02b7f6c + 9ff155e commit 4ee358c

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

samples/code-samples/Partitioning/DataModels/UserProfile.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public UserProfile(
4444
/// <summary>
4545
/// Gets or sets the primary region for the user.
4646
/// </summary>
47-
[JsonConverter(typeof(StringEnumConverter))]
4847
public Region PrimaryRegion { get; set; }
4948

5049
/// <summary>
@@ -55,7 +54,6 @@ public UserProfile(
5554
/// <summary>
5655
/// Gets or sets the status of the user.
5756
/// </summary>
58-
[JsonConverter(typeof(StringEnumConverter))]
5957
public UserStatus Status { get; set; }
6058

6159
/// <summary>

samples/code-samples/Partitioning/Program.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,19 +265,19 @@ private async Task RunCrudAndQuerySample(Database database, IPartitionResolver p
265265
UserProfile johnProfile = (UserProfile)(dynamic)latestJohnDocument;
266266
johnProfile.Status = UserStatus.Busy;
267267

268-
await this.client.ReplaceDocumentAsync(latestJohnDocument);
268+
await this.client.ReplaceDocumentAsync(latestJohnDocument.SelfLink, johnProfile);
269269

270270
// Query for John's document by ID. We can use the PartitionResolver to restrict the query to just the partition containing @John
271271
// Again the query uses the database self link, and relies on the hash resolver to route the appropriate collection.
272272
var query = this.client.CreateDocumentQuery<UserProfile>(database.SelfLink, null, partitionResolver.GetPartitionKey(johnProfile))
273273
.Where(u => u.UserName == "@John");
274274
johnProfile = query.AsEnumerable().FirstOrDefault();
275275

276-
// Query for all Available users. Here since there is no partition key, the query is serially executed across each partition/collection.
277-
query = this.client.CreateDocumentQuery<UserProfile>(database.SelfLink).Where(u => u.Status == UserStatus.Available);
278-
foreach (UserProfile activeUser in query)
276+
// Query for all Busy users. Here since there is no partition key, the query is serially executed across each partition/collection.
277+
query = this.client.CreateDocumentQuery<UserProfile>(database.SelfLink).Where(u => u.Status == UserStatus.Busy);
278+
foreach (UserProfile busyUser in query)
279279
{
280-
Console.WriteLine(activeUser);
280+
Console.WriteLine(busyUser);
281281
}
282282

283283
// Find the collections where a document exists in. It's uncommon to do this, but can be useful if for example to execute a
@@ -295,7 +295,6 @@ private async Task RunCrudAndQuerySample(Database database, IPartitionResolver p
295295
/// <summary>
296296
/// Illustrate how to load and save the serializer state. Uses HashPartitionResolver as example.
297297
/// </summary>
298-
/// <param name="hashResolver">The HashResolver instance.</param>
299298
private void RunSerializeDeserializeSample(HashPartitionResolver hashResolver)
300299
{
301300
// Store the partition resolver's configuration as JSON.
@@ -315,7 +314,7 @@ private void RunSerializeDeserializeSample(HashPartitionResolver hashResolver)
315314
/// Show how to repartition a hash resolver by adding/removing collections.
316315
/// </summary>
317316
/// <param name="database">The database to run the samples on.</param>
318-
/// <returns>The created HashPartitionResolver.</returns>
317+
/// <returns>The Task for the asynchronous execution.</returns>
319318
private async Task RepartitionDataSample(Database database)
320319
{
321320
var manager = new DocumentClientHashPartitioningManager(u => ((UserProfile)(dynamic)u).UserId, this.client, database, 3);

samples/code-samples/Queries/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ orderby f.Address.State descending
379379
// LINQ Lambda
380380
familiesLinqQuery = client.CreateDocumentQuery<Family>(collectionLink)
381381
.Where(f => f.LastName == "Andersen")
382-
.OrderByDescending(f => f.Children[0].Grade);
382+
.OrderByDescending(f => f.Address.State);
383383

384384
Assert("Expected only 1 family", familiesLinqQuery.ToList().Count == 1);
385385

0 commit comments

Comments
 (0)