-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asymmetric handling of DataContract with "Id" DataMember #427
Comments
Yup this is an issue will name collision. This is an issues with Newtonsoft json deserialzier JamesNK/Newtonsoft.Json#815 Implementation here actually delegated the conversion to Newtonsoft json through Object.ToObject(). One alternative is to use different NamingStrategy which will avoid the conflicting names. |
Wow! Thanks ... I'm really hoping that there is not too much lean away from DataContract and concretely coupled structure ... In fact, just the opposite ... I will certainly comment there. |
I thought I should post a comment here because I made a comment over on the NewtonSoft list ... It might not be the most critical possible viewpoint, but I HAVE to say that it's a bad experience to have it linger that "there is a case insensitivity that might mean X_Y_Z in your model". That's a headache. DataContract has been a very rock solid --- AND obvious. Now there is a new headache about the abstraction between POCO (!) objects and a representation. I'm still amazed that I could get an asymmetric result on what seems to be the first possible activity to make against Cosmos; and I am also still uneasy about some layer of transforms, converters, or handlers or something to get things right. Also PS: Cosmos is GREAT! |
@steevcoco work-around is to use different NamingStrategy to avoid the conflicting names. |
Hello ... I am completely new to DocumentDb (and want free advice Lol) -- I am just running simple tests.
If I push an object that is
DataContract
and defines aDataMember
named "Id" --- which I set myself. Then when reading back the object, AND then casting throughdynamic
to my own type, then thatDataMember
is set from the database "id" --- which doesn't seem symmetric at least.I don't know much about the bit of magic that allows me to cast through dynamic back to my object (I'd like to learn more about the round trip from DataContract) ... But the DataMember 'Id" wasn't used in the Db, so it's not stable to get it back that way.
... Edit 2:
[At one point, I thought perhaps it might be intended in some way ... You get back the Db-generated id. (I now see the
disableAutomaticIdGeneration
argument.) However, the round trip is not stable --- there is an "Id" (capital) going in, but a different one comes out; and the Db is fussy about the specific lowercase "id" DataMember name in other places ... so it does seem odd.][And for the record, I think it is far too lax not to have very concrete coupling to
DataContract
here.]This test displays the behavior (the final Cast is the significant bit):
The output is:
The text was updated successfully, but these errors were encountered: