How To

How to Install and configure a Windows Service from the command line
By Tan Lee Published on Mar 19, 2025 102

This article explains how to install, configure, query, and uninstall a Windows Service using command line utilities installutil.exe and sc.exe.

How to Deserialize JSON that Contains an Embedded JSON String in C#
By Tan Lee Published on Mar 19, 2025 126

In this article, I'll demonstrate how to handle deserializing JSON that contains an embedded JSON string, which I'll refer to as a "JSON package." This concept is like receiving a gift box (the JSON package) that contains a smaller gift (the embedded JSON data) inside it.

SqlException: Cannot insert explicit value for identity column
By Tan Lee Published on Mar 19, 2025 93

This error occurs because the table contains an identity column, and you're attempting to manually set a value for it. With an identity column, the value is automatically generated by the system during the insert, which is why you're not allowed to provide a value for this column.

How to find all the dependencies of a table in SQL Server
By Tan Lee Published on Mar 14, 2025 277

When working with a database in SQL Server, understanding the dependencies between tables, views, procedures, and other objects is essential. Often, you might need to track how tables are interconnected, especially when trying to identify which other tables, views, or stored procedures depend on a particular table.

How to Find Objects Referencing a Table in SQL Server
By Tan Lee Published on Mar 14, 2025 241

Renaming a table in SQL Server can be a tricky task, especially when there are numerous objects such as columns, stored procedures, functions, or views that rely on that table.

How to use JsonConverterFactory in C#
By Tan Lee Published on Mar 14, 2025 234

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
By Tan Lee Published on Mar 14, 2025 204

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
By Tan Lee Published on Mar 14, 2025 216

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
By Tan Lee Published on Mar 14, 2025 154

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#
By Tan Lee Published on Mar 14, 2025 166

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#
By Tan Lee Published on Mar 14, 2025 285

In C#, you can convert a string to a DateTime using the following methods:

How to batch read with Threading.ChannelReader in C#
By Tan Lee Published on Mar 13, 2025 214

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.