Creating models and customizing serialization
So far, we have been working with dynamic objects and we wrote SQL queries in strings without taking advantage of the beloved LINQ features. Now we will create a new version of the application that will use POCOs to represent the competitions. This way, we will be able to use strongly typed properties and work with LINQ to build queries instead of composing queries with strings.
Whenever we have to persist a document in the document database, the C# object that represents the document will be serialized to a JSON document; that is, it will be encoded in a string. Whenever we have to retrieve a document from the document database, the JSON document will be deserialized to the C# object that represents the document; that is, the object will be built from the string.
Note
One of the key benefits of working with Cosmos DB, its .NET Core SDK, and a document database based on the SQL API is that we don't have to use an Object-Relational Mapping (ORM)...