If you need a background task within .Net Core to be run at set times we can use the Hosted Service provided from the service within .Net Core.Continue reading Hosted Background timer task
A little hidden gem within .Net Core is the ability to run a Hosted Service inside the application. This allows for your service to run in a different thread to the main application, but keeps everything together though the need to host a separate service.Continue reading Hosting a service inside ASP.NET Core
Here are various was to convert enums to a lists
Get a List of Enum Members
The idea is to use
Enum.GetValues() method to get an array of the values of the constants in the enum. To get an
IEnumerable<T> of all the values in the enum, call
Cast<T>() on the array. To get a list, call
ToList() after casting.
The fastest way to perform a SQL record count is:
DECLARE @TableName sysname SET @TableName = 'Log' SELECT TBL.object_id, TBL.name, SUM(PART.rows) AS rows FROM sys.tables TBL INNER JOIN sys.partitions PART ON TBL.object_id = PART.object_id INNER JOIN sys.indexes IDX ON PART.object_id = IDX.object_id AND PART.index_id = IDX.index_id WHERE TBL.name = @TableName AND IDX.index_id < 2 GROUP BY TBL.object_id, TBL.name;
I love this smart template generator, saves so much time and effort.
Generates a unit test boilerplate from a given C# class, setting up mocks for all dependencies. Right click an item in Solution Explorer and choose “Create Unit Test Boilerplate” . Supports Visual Studio Test, NUnit, xUnit and many mock frameworks.
As defined by Polly “A circuit breaker detects the level of faults in calls placed through it, and prevents calls when a configurable fault threshold is exceeded”.Continue reading Circuit Breaker
What is a Resilience Framework?
Polly is classed as a resilience framework. A resilience framework is a set of libraries that help an application to recover from transient or more extended failures in services or infrastructure upon which it depends. When recovery is not possible, the resilience framework will facilitate graceful degradation of your application.
Polly has been around for many years and has been tried and tested in many applications
The source code for Polly can be found on GitHub here:Continue reading Fault tolerance using Polly
Throttling and rate-limiting allow you to prevent abuse of your API and ensure that your API withstands large numbers of calls (including DoS and accidental loops). With Throttling, you can set a delay on calls after an SLA tier has been exceeded, slowing down the number of requests an API client is making.Continue reading Throttling/Rate Limiter for an API
I came across a very good article on ASP.NET Core which I needed to bookmark, as it gives a clear and understandable guidance on keeping things working as efficiently as possible.Continue reading ASP.NET Core Guidance