833 热度

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.

收录时间: 2023-02-08
分类: C#
贡献者: Rector
525 热度

.Net6 微服务之Polly入门看这篇就够了

大家好!书接上文,本文将会继续建立在 .Net6 使用 Ocelot + Consul 看这篇就够了项目的基础上进行Polly的介绍,然后这篇文章只是个人学习与分享,不喜勿喷,谢谢!什么是Polly?Polly 是一个 .NET 弹性和瞬态故障处理库,允许开发人员以流畅和线程安全的方式表达重试、断路器、超时、隔板隔离、速率限制和回退等策略。https://github.com/App-vNext/Polly为什么要用到Polly?在单体项目中,一个业务流程的执行在一个进程中就完成了,但是在微服务项目中往往会涉及到多个服务甚至多台机器,而这些服务之间一般都是需要使用网络来进行...

收录时间: 2023-02-07
分类: .NET Core
贡献者: Rector
720 热度

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.

收录时间: 2023-01-30
分类: C#
贡献者: Rector
1063 热度

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.

收录时间: 2023-01-17
分类: C#
贡献者: Rector
622 热度

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.

收录时间: 2023-01-12
分类: C#
贡献者: Rector
672 热度

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.

收录时间: 2023-01-12
分类: ASP.NET Core
贡献者: Rector
AD 友情赞助
1035 热度

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#.

收录时间: 2023-01-12
分类: C#
贡献者: Rector
1189 热度

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.

收录时间: 2023-01-12
分类: .NET
贡献者: Rector
944 热度

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. In this article, we will learn how to add, access, and remove elements from a ConcurrentBag in C#. Then, we will discuss the advantages and disadvantages of this collection type.

收录时间: 2023-01-05
分类: C#
贡献者: Rector
959 热度

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 and ValueTask in C# is essential because using them correctly significantly enhances our app’s performance. In this article, we will try to understand what Task and ValueTask are and when to choose one over the other.

收录时间: 2023-01-05
分类: C#
贡献者: Rector
772 热度

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.

收录时间: 2023-01-05
分类: .NET
贡献者: Rector
729 热度

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.

收录时间: 2022-12-29
分类: C#
贡献者: Rector
516 热度

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.

收录时间: 2022-12-15
分类: .NET
贡献者: Rector
486 热度

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.

收录时间: 2022-12-14
分类: Visual Studio
贡献者: Rector
659 热度

.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.

收录时间: 2022-12-14
分类: .NET
贡献者: Rector
AD 友情赞助
739 热度

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.

收录时间: 2022-12-13
分类: .NET
贡献者: Rector
729 热度

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.

收录时间: 2022-12-08
分类: ASP.NET Core
贡献者: Rector
497 热度

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.

收录时间: 2022-12-08
分类: ASP.NET Core
贡献者: Rector
636 热度

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.

收录时间: 2022-12-08
分类: .NET 7
贡献者: Rector
557 热度

[亲测].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...

收录时间: 2022-12-04
分类: .NET 7
贡献者: Rector
AD 友情赞助