-
Type:
Task
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 1.6
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I have a collection in MongoDB which I'm trying to "FindAndModify" using C# driver. This collection holds types of a base class and its derived classed, as follows:
[BsonDiscriminator(RootClass = true)]
public class Father
{
public Guid Id
}
public class Son : Father
{
public string SomeProperty { get; private set; }
}
When I'm trying to cast the BsonDocument to my base class, after the FindAndModify, where the result is "Son":
Father modifiedDocument = result.GetModifiedDocumentAs<Father>();
I get the following exception:
System.IO.FileFormatException: Element 'SomeProperty' does not match any field or property of class Father.
Any idea why? -Can't I perform a down cast here?
Thanks,
Nir.