In an earlier post I introduced a strongly typed Identity object I am using in an ASP.Net Core application to make my code and error messages more readable. I didn’t wanted that extra complexity reflected in my database or over the wire with an API. In this post we’ll look at a simple method to map my strongly typed properties in C# to simpler values in JSON.
This is my desired state:
I want a strongly typed Identity object in my API backend that transparently converts into a simple int value to/from the database and converts to an int or
null for the front-end (null in cases...