Skip to content

Commit

Permalink
fix broken usage example code (#167) (#170)
Browse files Browse the repository at this point in the history
(cherry picked from commit bfb4e6f)
  • Loading branch information
jordan-smith721 authored Feb 23, 2024
1 parent 78d9c13 commit de7653c
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 41 deletions.
2 changes: 1 addition & 1 deletion source/includes/code-examples/GradeEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
6 changes: 5 additions & 1 deletion source/includes/code-examples/delete-many/DeleteMany.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Deletes multiple documents from a collection by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;

Expand Down Expand Up @@ -92,5 +96,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
8 changes: 5 additions & 3 deletions source/includes/code-examples/delete-many/DeleteManyAsync.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Asynchronously deletes multiple documents from a collection by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;

Expand All @@ -24,8 +28,6 @@ public static async Task Main(string[] args)
Console.WriteLine($"Deleted documents: {result.DeletedCount}");

Restore(docs);

return result;
}

private static async Task<DeleteResult> DeleteMultipleRestaurantsBuilderAsync()
Expand Down Expand Up @@ -94,5 +96,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
6 changes: 5 additions & 1 deletion source/includes/code-examples/delete-one/DeleteOne.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Deletes a document from a collection by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;

Expand Down Expand Up @@ -91,5 +95,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
6 changes: 5 additions & 1 deletion source/includes/code-examples/delete-one/DeleteOneAsync.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Asynchronously deletes a document from a collection by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;

Expand Down Expand Up @@ -91,5 +95,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
6 changes: 5 additions & 1 deletion source/includes/code-examples/find-many/FindMany.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Retrieves documents that match a query filter by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CSharpExamples.UsageExamples.FindMany;
Expand Down Expand Up @@ -111,5 +115,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
6 changes: 5 additions & 1 deletion source/includes/code-examples/find-many/FindManyAsync.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Asynchronously retrieves documents that match a query filter by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using MongoDB.Driver.Linq;

Expand Down Expand Up @@ -112,5 +116,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
3 changes: 2 additions & 1 deletion source/includes/code-examples/find-one/FindOne.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CSharpExamples.UsageExamples.FindOne;
Expand Down Expand Up @@ -97,5 +98,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
3 changes: 2 additions & 1 deletion source/includes/code-examples/find-one/FindOneAsync.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using MongoDB.Driver.Linq;

Expand Down Expand Up @@ -96,5 +97,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
9 changes: 5 additions & 4 deletions source/includes/code-examples/insert-many/InsertMany.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CSharpExamples.UsageExamples.InsertMany;
Expand Down Expand Up @@ -71,10 +72,10 @@ private static List<Restaurant> GenerateDocuments()
Name = "Mongo's Pizza",
RestaurantId = $"12345-{i}",
Cuisine = "Pizza",
Address = new BsonDocument
Address = new()
{
{"street", "Pizza St"},
{"zipcode", "10003"}
Street = "Pizza St",
ZipCode = "10003"
},
Borough = "Manhattan",
};
Expand Down Expand Up @@ -131,5 +132,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
9 changes: 5 additions & 4 deletions source/includes/code-examples/insert-many/InsertManyAsync.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CSharpExamples.UsageExamples.InsertMany;
Expand Down Expand Up @@ -71,10 +72,10 @@ private static List<Restaurant> GenerateDocuments()
Name = "Mongo's Pizza",
RestaurantId = $"12345-{i}",
Cuisine = "Pizza",
Address = new BsonDocument
Address = new()
{
{"street", "Pizza St"},
{"zipcode", "10003"}
Street = "Pizza St",
ZipCode = "10003"
},
Borough = "Manhattan",
};
Expand Down Expand Up @@ -131,5 +132,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
9 changes: 5 additions & 4 deletions source/includes/code-examples/insert-one/InsertOne.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CsharpExamples.UsageExamples.InsertOne;
Expand Down Expand Up @@ -38,10 +39,10 @@ private static void InsertOneRestaurant()
Name = "Mongo's Pizza",
RestaurantId = "12345",
Cuisine = "Pizza",
Address = new BsonDocument
Address = new()
{
{"street", "Pizza St"},
{"zipcode", "10003"}
Street = "Pizza St",
ZipCode = "10003"
},
Borough = "Manhattan",
};
Expand Down Expand Up @@ -108,5 +109,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
9 changes: 5 additions & 4 deletions source/includes/code-examples/insert-one/InsertOneAsync.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CsharpExamples.UsageExamples.InsertOne;
Expand Down Expand Up @@ -38,10 +39,10 @@ private static async Task InsertOneRestaurantAsync()
Name = "Mongo's Pizza",
RestaurantId = "12345",
Cuisine = "Pizza",
Address = new BsonDocument
Address = new()
{
{"street", "Pizza St"},
{"zipcode", "10003"}
Street = "Pizza St",
ZipCode = "10003"
},
Borough = "Manhattan",
};
Expand Down Expand Up @@ -108,5 +109,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
9 changes: 5 additions & 4 deletions source/includes/code-examples/replace-one/ReplaceOne.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CSharpExamples.UsageExamples.ReplaceOne;
Expand Down Expand Up @@ -48,10 +49,10 @@ private static ReplaceOneResult ReplaceOneRestaurant()
Id = oldId,
Name = "Mongo's Pizza",
Cuisine = "Pizza",
Address = new BsonDocument
Address = new()
{
{"street", "Pizza St"},
{"zipcode", "10003"}
Street = "Pizza St",
ZipCode = "10003"
},
Borough = "Manhattan",
};
Expand Down Expand Up @@ -110,5 +111,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
9 changes: 5 additions & 4 deletions source/includes/code-examples/replace-one/ReplaceOneAsync.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CSharpExamples.UsageExamples.ReplaceOne;
Expand Down Expand Up @@ -48,10 +49,10 @@ private static async Task<ReplaceOneResult> ReplaceOneRestaurant()
Id = oldId,
Name = "Mongo's Pizza",
Cuisine = "Pizza",
Address = new BsonDocument
Address = new()
{
{"street", "Pizza St"},
{"zipcode", "10003"}
Street = "Pizza St",
ZipCode = "10003"
},
Borough = "Manhattan",
};
Expand Down Expand Up @@ -110,5 +111,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
9 changes: 7 additions & 2 deletions source/includes/code-examples/update-many/UpdateMany.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Updates documents that match a query filter by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CSharpExamples.UsageExamples.UpdateMany;
Expand Down Expand Up @@ -41,8 +45,9 @@ private static UpdateResult UpdateManyRestaurants()
const string oldValue = "Pizza";
const string newValue = "Pasta and breadsticks";

// Creates a filter for all documents with a "cuisine" value of "Pizza"
var filter = Builders<Restaurant>.Filter
.Eq(restaurant => restaurant.Cuisine, oldValue);
.Eq(restaurant => restaurant.Cuisine, oldValue);

var update = Builders<Restaurant>.Update
.Set(restaurant => restaurant.Cuisine, newValue);
Expand Down Expand Up @@ -120,5 +125,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
9 changes: 7 additions & 2 deletions source/includes/code-examples/update-many/UpdateManyAsync.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Asynchronously updates documents that match a query filter by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;

namespace CSharpExamples.UsageExamples.UpdateMany;
Expand Down Expand Up @@ -41,8 +45,9 @@ private static async Task<UpdateResult> UpdateManyRestaurantsAsync()
const string oldValue = "Pizza";
const string newValue = "Pasta and breadsticks";

// Creates a filter for all documents with a "cuisine" value of "Pizza"
var filter = Builders<Restaurant>.Filter
.Eq(restaurant => restaurant.Cuisine, oldValue);
.Eq(restaurant => restaurant.Cuisine, oldValue);

var update = Builders<Restaurant>.Update
.Set(restaurant => restaurant.Cuisine, newValue);
Expand Down Expand Up @@ -120,5 +125,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
6 changes: 5 additions & 1 deletion source/includes/code-examples/update-one/UpdateOne.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Updates the first document that matches a query filter by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;

Expand Down Expand Up @@ -98,5 +102,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}
6 changes: 5 additions & 1 deletion source/includes/code-examples/update-one/UpdateOneAsync.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Asynchronously updates the first document that matches a query filter by using the C# driver

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;

Expand Down Expand Up @@ -98,5 +102,5 @@ public class GradeEntry

public string Grade { get; set; }

public float Score { get; set; }
public float? Score { get; set; }
}

0 comments on commit de7653c

Please sign in to comment.