-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.0
-
Component/s: BSON, Linq, Serialization
I have a class as follows:
class Person
{
public String Id
public String Name { get; set; }
public Person Mother
{ get; set; }}
I've implemented a custom serializer for the Mother property to serialize the Id only. The final BSON would look something like this:
[{ "_id": "54df1095fa0bd7122cb2c550", "name": "John", "mother":
{ "_id": "54df1095fa0bd7122cb2c551" }} ...]
If I try to execute a query to find a person with a given mother as follow:
var results = await collection.Find<Person> (p => p.Mother.Id == "...").ToListAsync ();
The driver complains with the following:
{"Unable to determine the serialization information for the expression: p.Mother.Id."}Is there a way to add serialization info to the driver so it knows to call my custom serializer to deserialize Person for this type of query?