Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1183

Adding serialization info for custom serializer

    XMLWordPrintableJSON

Details

    Description

      I have a class as follows:

      class Person
      {
      public String Id

      { get; set; }
      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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            gjdownes Graeme Downes
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: