[CSHARP-1183] Adding serialization info for custom serializer Created: 14/Feb/15  Updated: 05/Apr/19  Resolved: 14/Feb/15

Status: Closed
Project: C# Driver
Component/s: BSON, Linq, Serialization
Affects Version/s: 2.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Graeme Downes Assignee: Unassigned
Resolution: Done Votes: 0
Labels: c#, custom, linq,query, question, serialization
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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?



 Comments   
Comment by Graeme Downes [ 14/Feb/15 ]

Thanks. Apologies for the spam. I'll post my questions there exclusively from now on.

Comment by Craig Wilson [ 14/Feb/15 ]

I see that you've asked this on StackOverflow as well. Since we normally reserve JIRA for bug reports and feature requests, I'll go ahead and answer this question there.

http://stackoverflow.com/questions/28514352/adding-serialization-information-for-mongodb-custom-serializer

Generated at Wed Feb 07 21:38:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.