Is it possible to have some kind of type converter that allows Sync Framework to treat string "0"/"1" as boolean values for false/true. As per bool.parse documentation it is not supported by default so is there a way around it?
More details in case someone can suggest a different approach to this issue: I have a custom Sync Framework client implementation for android and as it uses SQLite database there is no way for me to enforce some strict datatype on table field. I could come up with the convention to indicate boolean field with, say, "Is" prefix, but that would be nasty. Another thing is that booleans in SQLite are treated as numeric type thus inserting/updating boolean false/true to the SQLite database automatically converts them to 0/1 and I do not want to introduce some TRUE/FALSE = 1/0 conversion on android side.
Any thoughts are welcome.
[UPDATE] More details: Server side consists of some services that are using Microsoft Sync Framework 4.0 CTP. There isn't a lot to configure except creating scope and so on. Client side generates changeset and transmits it to the server using JSON format. The changeset comes from the SQLite database (and SQLite doesn't have any native boolean representation except numeric 0/1), so when reading database there is no indication that coming data is of boolean type. Field value is serialized into JSON object as string with numeric value ("0" or "1") and thus server side fails while trying to parse it to a bool.
Btw it is possible to work around it if doing one-way client-to-server synchronisation. I manually set server side entity field type to byte and Sync Framework nicely uses it as a "bit" database type. This workaround doesn't work for server-to-client tho'.
The usual way in C#/.NET is to use Convert.ToBoolean()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With