How to provide custom property serializer delegate in a custom provider?
-
Monday, March 26, 2012 1:19 PM
Hello,
I am moving on with my attempt to implement MongoDB OData provider, and my next stop is serialization of properties that have CLR counterparts but are represented differently. One such property type is DateTime. MongoDB has its own DateTime type, and if I try to map MongoBD DateTime to CLR DateTime, then provider throws an exception saying that it is unable to serialize a primitive value. The exception is thrown from PlainXmlSerializer.PrimitiveToString() method. I checked the implementation and it looks that it's possible to override default behavior by providing custom DictionarySerializerDelegate. The problem is that it's internal functionality not to be used outside WCF Data Services classes.
So I wonder if this is possible at all using WCF Data Service to implement custom OData provider. A workaround is to map non-standard primitive data to strings, but this is kind of dirty (and killes search possibilities for such properties).
Thanks in advance
UPDATE. I think I've solved it. Of course I get a chance to override the value when I wrap native data into a DSPResource instance. No need to intervene with DictionarySerializerDelegate.
Vagif Abilov
- Edited by Vagif Abilov Monday, March 26, 2012 1:59 PM
- Changed Type Alan_chenModerator Tuesday, March 27, 2012 8:16 AM
All Replies
-
Tuesday, March 27, 2012 8:16 AMModerator
Hi Vagif,
Thanks for sharing your experience here.
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.


