You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Docs/reference/content/reference/driver/crud/index.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,3 +36,17 @@ Animal
36
36
```
37
37
38
38
The collection instance must be an [`IMongoCollection<Animal>`]({{< apiref "T_MongoDB_Driver_IMongoCollection_1" >}}).
39
+
40
+
41
+
#### Working with Subclasses
42
+
43
+
The [`OfType`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_OfType_1">}}) method applies a discriminating filter to all methods of an [`IMongoCollection<T>`]({{< apiref "T_MongoDB_Driver_IMongoCollection_1" >}}). For example, to work only with `Cats` from the "animals" collection:
{{% note class="warning" %}}It is imperative that the collection retrieved from the database instance be the root of the hierarchy. `db.GetCollection<Cat>("animals")` will NOT include the discriminator.{{% /note %}}
0 commit comments