WebLog

Server-side, client-side, code snippets, scripts, automation, best practices, proven approaches, tips & tricks...

Adding centralized secrets service to Azure Service Fabric cluster

Adding secrets store and using store secrets in Azure Service Fabric
0
Azure Service Fabric is a great platform to host services for your distributed solution. It allows you to easily deploy and scale your applications and services. Apart from these out of the box functionalities which it is essentially build for, it also comes with secrets service which allows you to store and retrieve secret values for your application...read more

C# scripting with .NET Core global tool

Using .NET Core global tool to run C# script files
0
I assume since you are reading this article you are involved in development of applications using C# and .NET platform. Microsoft .NET and C# have been around for quite a while but there is not much talk on haw you can use C# for writing code apart from creating your projects in your IDE of choice and compiling them to executables. This is typical approach for writing robust applications and that is fine, but from time to time, this whole ceremony of creating a project, adding packages and libraries just to run for example a simple scheduled task that cleans up old logs from IIS seems like and overkill...read more

Customizing PowerShell terminal with oh-my-posh v3

Setting up oh-my-posh v3 custom theme for PowerShell
 
0
Last year I wrote an article on how to Customizing WSL2 on Windows with screenfetch and oh-my-zsh as I was spending a lot of time in WSL2 doing some heavy development for Linux platform using .NET Core. However recently I found myself working a lot in PowerShell prompt mainly with Git and really missed the customization I did for WSL, so I decided to customize my PowerShell console as well...read more

Using interceptors with dependency injection in Entity Framework Core

EF Core interceptors via dependency injection in ASP.NET 5
 
0
I while ago I wrote an article on how to Access multiple databases from the same DbContext in EF Core which relies on interceptors to mutate the SQL query diring execution. This code works just fine and it updates the command prior to it's execution, but it lacks in option to inject registered services to it's constructor as i used new keyword to initialize class instances. Adding interceptor without dependency injection ...read more

Implementing soft delete in EF Core using triggers

Entity soft delete implementation in EF Core
 
0
Implementation approach for soft delete is more-less straight forward thing. Instead of deleting data record, you introduce a flag which will mark the record as deleted and you can simply filter out on it and not show the data with the flag set. This way you do not loose data, but you restrict the end user to see it. This way of "deleting" data records, or better said marking them as deleted applies for certain types of applications, but sometime this requirement may come later as a new feature while the actual delete is in place...read more

Setting Azure DevOps pipeline variable from PowerShell script

Output value from PowerShell script to Azure DevOps builds and releases
 
0
When using Azure DevOps Pipelines or Releases, it is pretty easy to move informations from the pipeline/release into the target artifact package or folder on the target environment. What can be tricky if you need to dictate your pipeline/release based on the value from your code base or maybe the environment to which you are deploying to. As a simple example I set the version attribute in in my .csproj file which I will use to tell UseDotNet task in my build pipeline which SDK to use to perform .NET Core project build. ...read more

Mocking view mapped DbSets with XUnit in EF Core

Writing unit tests for view bounded entities in EF Core
 
 
0
Using in-memory DbContext is a great way to mock your actual DbContext in unit tests. You basically initialize the instance of your DbContext and seed some random data before you assert the result of your repository method. Now the problem occurs if you are mapping database view to an entity...read more

Setting up SQL Server IDistributedCache with migration in ASP.NET Core

Embedding SQL Server caching in a project with EFCore migration
 
0
Caching data using Microsoft SQL Server may not be the most popular way of caching data because of the performance comparing to caching data to Redis, but it is maybe the most convenient way to keep your state of the application outside the process itself. Beside, if you are already using SQL Server database, you can just move the caching infrastructure to a separate schema inside the same database and keep using it until requirements are met for cache storage of better performance (like Redis for example). This makes infrastructure not so complex and less dependent, again until the requirements for something faster are met. ...read more

Representing available string values for parameters as list in Swagger ASP.NET Core

Valid values as list in Swagger UI in ASP.NET Core
 
 
0
Swagger is a great way do describe your RESTful API. In ASP.NET it is pretty easy to wire up your OpenAPI documentation with your service facade with Swashbuckle NuGet package. In .NET 5, WebApi project template comes with already built in support for OpenAPI via Swashbuckle package and you can get it already setup in your pipeline and dependency injection with an easy tick in new WebApi project in Visual Studio. ...read more

Running multiple queries at the same time in EF Core

Overcoming the limitation of EF Core query execution
 
 
0
Since the time of ADO in .NET one of the limitations was that one connection can execute single command at the time. Same limitation Entity Framework inherited and you can execute single command at the time per instance of your DbContext. Typical dependency injection lifetime of DbContext is scoped, which means you can execute one command at the time as the DbContext is instantiated per HTTP request in ASP.NET Core application. ...read more

Accessing multiple databases from the same DbContext in EF Core

Multiple database access from the same DbContext in Entity Framework Core 5
 
 
0
It is not uncommon to have a requirement to access tables or views in different databases in the same query. In order to be able to do your joins on tables or views in different databases you need to do it in the same connection instance which is bound to DbContext, therefore this access as to be accomplished from the same DbContext instance...read more

JavaScript

read more

Umbraco CMS

read more

.NET

read more

SQL/T-SQL

read more