JSON converter on azure mobile service queries -


one of tables in azure mobile has column defined number. on client side column maps enum. have json converter marshals enum value int (code below).

class completedstateconverter : jsonconverter {     public override bool canconvert(type objecttype)     {         return objecttype == typeof(completedstate);     }      public override object readjson(jsonreader reader, type objecttype, object existingvalue, jsonserializer serializer)     {         if (reader.tokentype == jsontoken.null)             return completedstate.notcompleted;         int intval = serializer.deserialize<int>(reader);         completedstate gamecompleted = (completedstate)intval;         return gamecompleted;     }     public override void writejson(jsonwriter writer, object value, jsonserializer serializer)     {         completedstate gamecompleted = (completedstate)value;         int number = (int)gamecompleted;         serializer.serialize(writer, number);     } } 

all worked fine until needed make change in 1 of queries use read data table.

data = await app.gametable                .take(15)                .orderbydescending(g => g.lastmovetime)                .where(g => g.completed == completedstate.notcompleted)                .tolistasync(); 

notice clause selects items completed state notcompleted (value of 0 in enum list).

on backend query gets translated string instead of using number should provided json converter.

here's content of query.getcomponents()

{   "filters":     {       "operator":"and",       "left":{"querystring":"(completed eq 'notcompleted')","args":[],"type":"literalexpression"},       "right":         {           "operator":"or",           …removed           "type":"binaryexpression"         },       "type":"binaryexpression"     },   "selections":[],   "projection":null,   "ordering":{"lastmovetime":false},   "skip":null,   "take":15,   "table":"game",   "includetotalcount":false,   "version":4 } 

i expected query leverage json converter convert enum number. why isn’t doing , should make work?

thank you


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -