PostgreSQL in C# .NET with Npgsql, Dapper, and Entity Framework: The Complete Guide
We’ll talk today about combining Postgres with my favorite language and runtime: C# and .NET. Just because Postgres isn’t a first-party Microsoft database, like SQL Server, doesn’t mean you don’t have full support for it in C#. You absolutely do, and in this article, you’ll see modern ways to do just that. You’ll see how to interact between Postgres and C# using the standard data provider library Npgsql, use it with Dapper, and even with Entity Framework. We’ll go over the basic operations like creating a table, inserting rows, deleting, and updating records using all of these frameworks.
.Net6 微服务之Polly入门看这篇就够了
大家好!书接上文,本文将会继续建立在 .Net6 使用 Ocelot + Consul 看这篇就够了项目的基础上进行Polly的介绍,然后这篇文章只是个人学习与分享,不喜勿喷,谢谢!什么是Polly?Polly 是一个 .NET 弹性和瞬态故障处理库,允许开发人员以流畅和线程安全的方式表达重试、断路器、超时、隔板隔离、速率限制和回退等策略。https://github.com/App-vNext/Polly为什么要用到Polly?在单体项目中,一个业务流程的执行在一个进程中就完成了,但是在微服务项目中往往会涉及到多个服务甚至多台机器,而这些服务之间一般都是需要使用网络来进行...
ConcurrentDictionary in C# - Detailed Guide
We’ve already written about a regular Dictionary in C#. We’ve also explored the basics of ConcurrentDictionary as one of many Concurrent Collections in C#. In this article, we will go into more detail and explore the use cases in which ConcurrentDictionary can be useful to us.
Encrypting and Decrypting a String in C#
In this article, we will learn how encrypting and decrypting a string is done using C# and the Cryptography package that comes included with .NET.
Generic Attributes in C#
In this article, we are going to learn how generic attributes help us implement better custom attributes through a practical example.
Mocking dependencies in ASP.NET Core tests
As I recently spent some time writing and refactoring tests that utilize WebApplicationFactory, I’ve come to have some thoughts and ideas for improvement that I’d like to share. In this article, I’ll delve into the process of mocking dependencies in a DI container when using WebApplicationFactory, and offer some insights and best practices I’ve learned along the way. Whether you’re a seasoned pro or new to unit testing ASP.NET Core applications, I hope this information will be helpful as you work to simplify and streamline your tests.
How to Iterate Over JSON Objects in C#
Manipulating JSON objects is a common operation in applications. In this article, we will look at different ways of iterating over JSON objects in C#.
Rebus in .NET - Service Bus Implementation
When working with distributed applications that need to asynchronously communicate with each other, the “Publish-Subscribe” pattern is very common. To avoid being tightly coupled to a message broker, such as RabbitMQ, we use an abstraction layer, known as a service bus. Rebus is one such service bus implementation for .NET that allows us to easily communicate asynchronously between services. This article makes use of Docker to run our message broker (RabbitMQ) server locally.
ConcurrentBag in C#
In C#, there are many classes that we can use to represent a group of objects that we may manipulate concurrently using multiple threads. One such class is the ConcurrentBag
Understanding Task and ValueTask in C#
If we want to optimize our code and improve the performance of our app, there is no one go-to solution. Instead, we analyze our code and try to find where to improve. Understanding Task
How to Add a BearerToken to an HttpClient Request
Often, in our daily routine, we have to deal with secure APIs and use a BearerToken to make HTTP requests. In this article, we are going to learn the correct way to add a BearerToken to an HttpClient request.
IEnumerable in C#
In this article, we are going to learn about IEnumerable in C#. IEnumerable acts as an abstraction over a collection and allows us to iterate over it without knowing the actual type of the collection.
Working With Collections in .NET
When we develop software applications, we may need to create, store and manipulate groups of related objects. In this article, we will discuss the various ways in which we can perform such operations using different collections in .NET.
Try out Visual Studio 2022 version 17.5 Preview 2
I’m excited to share today we released Visual Studio 2022 17.5 Preview 2! Your feedback goes directly to the product team working to deliver you the best developer IDE. We welcome your feedback on Developer Community where we are always eager to hear your suggestions for new or existing features and learn about any bugs or issues via report a problem.
.NET December 2022 Updates – .NET 7.0.1, .NET 6.0.12, .NET Core 3.1.32
Today, we are releasing the .NET December 2022 Updates. These updates contain security and non-security improvements. Your app may be vulnerable if you have not deployed a recent .NET update. You can download 7.0.1, 6.0.12, and 3.1.32 versions for Windows, macOS, and Linux, for x86, x64, Arm32, and Arm64.
Schedule Jobs with Quartz.NET
Recurring, background tasks are widespread and very common when building applications. These tasks can be long-running or repetitive and we don’t want to run them in the foreground, as they could affect the user’s experience of the application. So instead we must schedule these jobs to run in the background somewhere. To achieve this in .NET, we can use the Quartz.NET library to manage the creation and scheduling of these jobs. This article makes use of Docker to run SQL Server server locally. Optionally a local install of SQL Server can be used.
How to Extract Custom Header in ASP.NET Core Web API
In this article, we are going to learn about the different ways we can extract Custom Headers from our ASP.NET Core Web API requests.
Implement Feature Management in Blazor ASP.NET Core
The post shows how features toggles or feature switches can be implemented in an ASP.NET Core application using Blazor. The Microsoft.FeatureManagement Nuget package is used to add the feature toggles.
5 new MVC features in .NET 7
Many of the headline features introduced in ASP.NET Core in .NET 7 were about minimal APIs, such as route groups and filters. But just because minimal APIs were a big focus doesn't mean that MVC controllers were left out in the cold! In this post I discuss some new MVC features that were introduced in .NET 7.
[亲测].NET Core(.NET 7)Web应用部署到Ubuntu的Docker容器并配置Nginx反向代理及Let's Encrpt SSL证书自动续期
本文将为C#&.NET开发者介绍《.NET Core(.NET 7)Web应用部署到Ubuntu的Docker容器并配置Nginx反向代理及Let’s Encrpt SSL证书自动续期》。先看最终部署和运行的效果图:本文你将学习到:如何在Ubuntu中创建用户;如何在Ubuntu中将用户添加到sudo组;如何在Ubuntu中安装Nginx;如何在Ubuntu中使用Certbot插件获取SSL证书;如何使用Visual Studio 2022创建.NET 7 Web网站应用程序;如何将.NET Core(.NET 7)Web应用程序制作成本地Docker镜像;如何在Ubuntu服务器的Doc...