How To
How to use JsonConverterFactory in C#
3/14/2025 3:45:51 AM 118
To use a JsonConverterFactory in C#, you need to create a custom JsonConverterFactory subclass and implement the necessary methods.
How to serialize non-public properties using System.Text.Json
3/14/2025 3:30:37 AM 112
By default, System.Text.Json.JsonSerializer only serializes public properties. If you need to serialize non-public properties, you have two main options:
The JSON value could not be converted to System.DateTime
3/14/2025 3:19:03 AM 108
When using System.Text.Json to deserialize a DateTime value, an error occurs if the value is not in the expected format. The default expected format is the ISO-8601-1:2019 format, such as 2025-03-12T12:35:34+00:00.
Case sensitivity in SQL Server
3/14/2025 3:13:35 AM 66
In SQL Server, the collation property controls case sensitivity. Case sensitivity can affect how data is sorted and queried, even down to column names, which must match exactly in a case-sensitive database setting.
Try/finally with no catch block in C#
3/14/2025 3:05:32 AM 88
In C#, a try/finally block is particularly useful when you need to guarantee certain actions will always be executed at the end of a method, regardless of whether an exception was thrown.
Parsing a DateTime from a string in C#
3/14/2025 2:56:59 AM 136
In C#, you can convert a string to a DateTime using the following methods:
How to batch read with Threading.ChannelReader in C#
3/13/2025 3:13:43 AM 102
In scenarios involving a consumer/producer model, batching the consumption of items can be highly beneficial. Whether you’re inserting a bulk of records into a database or sending multiple data packets over HTTP, sending individual items one by one can be inefficient.
How to ignore JSON deserialization errors in C#
3/13/2025 3:05:04 AM 147
A single deserialization error can cause the entire process to fail.
JsonException: A possible object cycle was detected
3/13/2025 2:56:52 AM 96
When serializing objects in .NET, you may encounter a JsonException due to circular references between objects.
JSON value could not be converted to System.String in C#
3/13/2025 2:50:08 AM 166
When you send a request to an ASP.NET API with a JSON body, you might encounter the following exception:
Calling ‘BuildServiceProvider’ from application code results in an additional copy of singleton services being created
3/13/2025 2:44:26 AM 125
When calling BuildServiceProvider() in your application, you may encounter this warning:
How to use Newtonsoft in ASP.NET Core
3/13/2025 2:37:33 AM 102
To use Newtonsoft.Json in an ASP.NET Core application instead of the default System.Text.Json, follow these steps: