Skip to content

Commit bfb4e6f

Browse files
fix broken usage example code (#167)
1 parent a1e0ce2 commit bfb4e6f

File tree

19 files changed

+70
-44
lines changed

19 files changed

+70
-44
lines changed

source/includes/code-examples/GradeEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ public class GradeEntry
44

55
public string Grade { get; set; }
66

7-
public float Score { get; set; }
7+
public float? Score { get; set; }
88
}

source/includes/code-examples/delete-many/DeleteMany.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Deletes multiple documents from a collection by using the C# driver
22

3+
using MongoDB.Bson;
4+
using MongoDB.Bson.Serialization.Attributes;
35
using MongoDB.Bson.Serialization.Conventions;
46
using MongoDB.Driver;
57

@@ -98,5 +100,5 @@ public class GradeEntry
98100

99101
public string Grade { get; set; }
100102

101-
public float Score { get; set; }
103+
public float? Score { get; set; }
102104
}

source/includes/code-examples/delete-many/DeleteManyAsync.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Asynchronously deletes multiple documents from a collection by using the C# driver
22

3+
using MongoDB.Bson;
4+
using MongoDB.Bson.Serialization.Attributes;
35
using MongoDB.Bson.Serialization.Conventions;
46
using MongoDB.Driver;
57

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

2830
Restore(docs);
29-
30-
return result;
3131
}
3232

3333
// Deletes all documents that have a Borough value of "Brooklyn"
@@ -100,5 +100,5 @@ public class GradeEntry
100100

101101
public string Grade { get; set; }
102102

103-
public float Score { get; set; }
103+
public float? Score { get; set; }
104104
}

source/includes/code-examples/delete-one/DeleteOne.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Deletes a document from a collection by using the C# driver
22

3+
using MongoDB.Bson;
4+
using MongoDB.Bson.Serialization.Attributes;
35
using MongoDB.Bson.Serialization.Conventions;
46
using MongoDB.Driver;
57

@@ -95,5 +97,5 @@ public class GradeEntry
9597

9698
public string Grade { get; set; }
9799

98-
public float Score { get; set; }
100+
public float? Score { get; set; }
99101
}

source/includes/code-examples/delete-one/DeleteOneAsync.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Asynchronously deletes a document from a collection by using the C# driver
22

3+
using MongoDB.Bson;
4+
using MongoDB.Bson.Serialization.Attributes;
35
using MongoDB.Bson.Serialization.Conventions;
46
using MongoDB.Driver;
57

@@ -95,5 +97,5 @@ public class GradeEntry
9597

9698
public string Grade { get; set; }
9799

98-
public float Score { get; set; }
100+
public float? Score { get; set; }
99101
}

source/includes/code-examples/find-many/FindMany.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Retrieves documents that match a query filter by using the C# driver
22

3+
using MongoDB.Bson;
34
using MongoDB.Bson.Serialization.Conventions;
5+
using MongoDB.Bson.Serialization.Attributes;
46
using MongoDB.Driver;
57

68
namespace CSharpExamples.UsageExamples.FindMany;
@@ -116,5 +118,5 @@ public class GradeEntry
116118

117119
public string Grade { get; set; }
118120

119-
public float Score { get; set; }
121+
public float? Score { get; set; }
120122
}

source/includes/code-examples/find-many/FindManyAsync.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Asynchronously retrieves documents that match a query filter by using the C# driver
22

3+
using MongoDB.Bson;
34
using MongoDB.Bson.Serialization.Conventions;
5+
using MongoDB.Bson.Serialization.Attributes;
46
using MongoDB.Driver;
57
using MongoDB.Driver.Linq;
68

@@ -117,5 +119,5 @@ public class GradeEntry
117119

118120
public string Grade { get; set; }
119121

120-
public float Score { get; set; }
122+
public float? Score { get; set; }
121123
}

source/includes/code-examples/find-one/FindOne.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using MongoDB.Bson;
44
using MongoDB.Bson.Serialization.Conventions;
5+
using MongoDB.Bson.Serialization.Attributes;
56
using MongoDB.Driver;
67

78
namespace CSharpExamples.UsageExamples.FindOne;
@@ -101,5 +102,5 @@ public class GradeEntry
101102

102103
public string Grade { get; set; }
103104

104-
public float Score { get; set; }
105+
public float? Score { get; set; }
105106
}

source/includes/code-examples/find-one/FindOneAsync.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using MongoDB.Bson;
44
using MongoDB.Bson.Serialization.Conventions;
5+
using MongoDB.Bson.Serialization.Attributes;
56
using MongoDB.Driver;
67
using MongoDB.Driver.Linq;
78

@@ -100,5 +101,5 @@ public class GradeEntry
100101

101102
public string Grade { get; set; }
102103

103-
public float Score { get; set; }
104+
public float? Score { get; set; }
104105
}

source/includes/code-examples/insert-many/InsertMany.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using MongoDB.Bson;
44
using MongoDB.Bson.Serialization.Conventions;
5+
using MongoDB.Bson.Serialization.Attributes;
56
using MongoDB.Driver;
67

78
namespace CSharpExamples.UsageExamples.InsertMany;
@@ -93,10 +94,10 @@ private static List<Restaurant> GenerateDocuments()
9394
Name = "Mongo's Pizza",
9495
RestaurantId = $"12345-{i}",
9596
Cuisine = "Pizza",
96-
Address = new BsonDocument
97+
Address = new()
9798
{
98-
{"street", "Pizza St"},
99-
{"zipcode", "10003"}
99+
Street = "Pizza St",
100+
ZipCode = "10003"
100101
},
101102
Borough = "Manhattan",
102103
};
@@ -153,5 +154,5 @@ public class GradeEntry
153154

154155
public string Grade { get; set; }
155156

156-
public float Score { get; set; }
157+
public float? Score { get; set; }
157158
}

0 commit comments

Comments
 (0)