-
Notifications
You must be signed in to change notification settings - Fork 85
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
Json serialization of longs to strings #70
Comments
Wouldn't that concern be part of your application? I would assume something like AutoMapper to map from your domain db object to the DTO model where Id would be long StronglyTypedId backed value in your domain db entity and ID would then be a string in your DTO object.
|
If you have an anemic domain, you could. Or if your domain is 99% similar to your DTO. In my case, domain objects are not DB entities, and while I can have some properties in common between entity<->dto, I never map them using a mapper. At least not for commands. Queries, on the other hand, do get mapped, since those are usually quite similar to what I have in the DB. |
I guess I'm just lost on where the use case is for this. |
Sorry for the delay with this 😳. To be honest I got overwhelmed with how to handle the big range of feature requests and options. I think I've found an answer in the big redesign of the library in this PR: The main idea is to make the library much more maintainable while also giving people a mechanism to customise the generated IDs as much as they like. This will make it easy to make changes like this, as you can simply provide a custom template that you can use which has the desired functionality 🙂 |
I know this is a very specific case, but... Javascript doesn't support longs. They are trimmed down to the nearest 53bit integer. I have a DB where Ids are longs so I implemented a custom json converter for my webapi that simply writes longs as strings and parse them back from strings (instead of using real js numbers).
I can't do the same with STI, as the serializer it generates simply does a
writer.WriteNumberValue(value.Value);
. That's fine inside the .net realm, but not in javascript.I would like an option to be able to specify that longs should be [de]serialized as strings instead of numbers.
Would that be possible? Not sure about any other options that could solve the problem in a generic way.
The text was updated successfully, but these errors were encountered: