Category Archives: .net

Create C# Class from SQL

I hate doing plumbing code. Especially entity model classes that are exact replicas of SQL tables. I do this all the time when using Dapper. So I did some googling and found some SQL statements that you can run in … Continue reading

Posted in .net, c# | Tagged , , , , , | Leave a comment

C# Thread Safe File Writer and Reader

Previously I wrote the article Write to file from multiple threads async with C# and .NET Core, which explains how to use a ConcurrentQueue to append lines to a text file. And the ConcurrentQueue is great for the fire-and-forget scenarios of … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , , , | Leave a comment

C# Log to Application Insights and File from your .NET 6 Application

So why would you ever log to Application Insights AND File log at the same time? Well, if you are hosting your own applications on your own machine, it can be great to have a file version of what’s happened. … Continue reading

Posted in .net, .NET Core, c#, General .NET, Microsoft Azure | Tagged , , , | 2 Comments

Get Users from IdentityServer using .NET Core

If you wish to poke around in the IdentityServer users database directly, the API seems a little bit fishy. This is because the direct data access are very low level, and consists of HttpClient extension methods. They are, in fact, … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , , , | Leave a comment

Host .net core 6.0 WebApplication as Kestrel Windows Service

If you create a .NET Core 6.0 Web Application as default, the application will run as an App Service just fine. But if you wish to host the application yourself, you can run the application as a Windows Service. This … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , | Leave a comment

C# .NET Core API Versioning with Microsoft.AspNetCore.Mvc.Versioning

.NET Core allows you to control versions of your APIs. To do so you need the following NuGet package: Microsoft.AspNetCore.Mvc.Versioning But lets try to version our API. STEP 1: CREATE A CONTROLLER Notice how I in line 6 defines the … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , | Leave a comment

Read and Update Azure App Configuration settings with C#

Azure App Configuration is a nifty way of storing configuration settings in the cloud, and with the live reload feature you can change the config settings and they will automatically update in your app without a need for redeploy. But … Continue reading

Posted in .net, .NET Core, c#, General .NET, Microsoft Azure | Tagged , , , , | Leave a comment

C# Deserialize JSON to dynamic ExpandoObject()

The Microsoft System.Text.Json.Serialization.JsonSerializer cannot (yet) convert JSON into dynamic objects. But good ole Newtonsoft.Json can. The conversion is simple too: After the conversion, you can work with the dynamic object as you wish: MORE TO READ: How to serialize and … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , , | Leave a comment

.NET 6.0 and Simple (minimal) Api’s: Create an Api without controllers

Have you always dreamt of skipping the controllers in your Web Api? Are you the lazy type? And have you always wanted to return data directly from your repositories? Feat not, .NET 6.0 to your rescue. The new “Minimal Api” … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , | 1 Comment

C# DateTime to UNIX timestamps

Although the UNIX timestamp (also known as the EPOCH time or the POSIX time) probably does not make sense to you, it is still widely used. After all, who cares how many seconds have elapsed since Jan 1st 1970, right? … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , , | Leave a comment