1220 热度

.NET Core MongoDB数据仓储和工作单元模式实操

上一章节我们主要讲解了MongoDB数据仓储和工作单元模式的封装,这一章节主要讲的是MongoDB用户管理相关操作实操。如:获取所有用户信息、获取用户分页数据、通过用户ID获取对应用户信息、添加用户信息、事务添加用户信息、用户信息修改、用户信息删除等实战教程。

收录时间: 2023-04-11
分类: .NET Core
贡献者: Rector
1188 热度

.NET Core(.NET 7)如何使用Dapper连接PostgreSQL数据库并实现CRUD(新增,查询,修改,删除)的超详细入门示例教程

PostgreSQL是一款开源的对象关系型数据库管理系统(ORDBMS)。它与常见的关系型数据库管理系统(RDBMS)如MySQL、Oracle和Microsoft SQL Server等不同,因为它具有更多高级功能,如对象存储、复杂查询和规范化等。PostgreSQL提供了.NET Core(.NET 7)的连接驱动,对于一个专注C#&.NET的作者来说,写一篇关于《.NET Core(.NET 7)如何使用Dapper连接PostgreSQL数据库并实现CRUD(新增,查询,修改,删除)的超简单入门示例教程》也就顺理成章了。那么,本文就为大家分享在C#&.NET Core(.NET 7...

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

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

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

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

Bring WCF apps to the latest .NET with CoreWCF and Upgrade Assistant

Since CoreWCF 1.0 was released in April, we have received customer interest in tooling to assist the upgrade from WCF on .NET Framework to CoreWCF on .NET 6 and later versions of .NET. We are happy to announce that the team has released the Preview version of CoreWCF extension for C# projects in Upgrade Assistant that does most of the steps needed for the upgrade. In this blog, we will walk through the migration experience using Upgrade Assistant on a simple WCF project.

收录时间: 2022-11-07
分类: .NET Core
贡献者: Rector
852 热度

Console.ReadKey improvements in .NET 7

.NET continues to improve its Unix/Linux support in .NET 7. One of the aspects that was improved in RC1 was Console.ReadKey, which has been rewritten from scratch. Key combinations are more accurately handled across many Linux distros and terminals, and modifier keys are especially improved.

收录时间: 2022-10-12
分类: .NET Core
贡献者: Rector
1447 热度

Running .NET Core Applications as a Linux Service

In this article, we are going to learn how to run a .NET application as a Linux service. Linux operating system contains a service manager called Systemd. The Systemd acts as an initialization system and controls what programs and services run when the system boots up. While working with Linux, we can make use of Systemd to manage our services.

收录时间: 2022-07-28
分类: .NET Core
贡献者: Rector
AD 友情赞助
1059 热度

Adding content negotiation to minimal APIs with Carter

In my previous post I described how to return XML from a minimal API endpoint. In this post I look at an alternative approach, using the open source library, Carter.

收录时间: 2022-07-13
分类: .NET Core
贡献者: Rector
1680 热度

Running .NET Core Applications as a Windows Service

In this article, we are going to learn how to create a .NET Core Worker Service and run it as a Windows Service.

收录时间: 2022-07-01
分类: .NET Core
贡献者: Rector
1161 热度

Using MySQL in a Docker container with EF Core

Recently I’ve been asked for a sample using EF Core with MySQL. When using EF Core I’m using Micorosft SQL Server or Azure Cosmos DB – and you have many code samples for EF Core in my book Professional C# and .NET, 2021 Edition. To demonstrate using EF Core I took one of the existing samples and changed the SQL Server provider to a MySQL provider. For not needing to install MySQL on my system, I’m using a Docker image as you can read here...

收录时间: 2022-05-18
分类: .NET Core
贡献者: Rector
1408 热度

.NET 4.x app running in a container using Docker

So this blog post comes from doing some work recently to containerize a .Net 4.8 project that needs to run on a Windows container. I wrote about Windows containers already so this is going to be some other tips to help someone who may have run into the same issues I did.

收录时间: 2022-03-12
分类: .NET Core
贡献者: Rector
1719 热度

Create a RESTful API with .NET Core and MongoDB

If you've been keeping up with my development content, you'll remember that I recently wrote Build Your First .NET Core Application with MongoDB Atlas, which focused on building a console application that integrated with MongoDB. While there is a fit for MongoDB in console applications, many developers are going to find it more valuable in web applications. In this tutorial, we're going to expand upon the previous and create a RESTful API with endpoints that perform basic create, read, update, and delete (CRUD) operations against MongoDB Atlas.

收录时间: 2022-02-09
分类: .NET Core
贡献者: Rector
1276 热度

.Net Core——用SignalR撸个游戏

之前开内部培训,说到实时web应用这一块讲到了SignalR,我说找时间用它做个游戏玩玩,后面时间紧张就一直没安排。这两天闲了又想起这个事,考虑后决定用2天时间写个斗D主,安排了前端同学写客户端,我写游戏逻辑和服务。这个项目难度并不高,但是游戏逻辑还是挺绕的,联调过程中也发现解决了很多小问题。来园子里整理一篇文章,记录一下。基础的介绍就免了,毕竟官网跟着走两圈啥都懂了。没基础的可以戳这里,是我之前写的一篇SignalR基础介绍,带有一个极简聊天室。tips:文章结尾有开源地址,游戏数据都是本地的,改下IP运行起来就可以玩了。直接上干货,首先是数据模型...

收录时间: 2022-01-04
分类: .NET Core
贡献者: Rector
1906 热度

一行代码完成定时任务调度,基于Quartz的UI可视化操作组件 GZY.Quartz.MUI

之前发布过第一个版本,有兴趣的可以去看看:NET Core 基于Quartz的UI可视化操作组件 GZY.Quartz.MUI 简介GitHub开源地址:l2999019/GZY.Quartz.MUI: 基于Quartz的轻量级,注入化的UI组件 (github.com) (欢迎点Start收藏~)总而言之,这个组件主要想做的就是:像swaggerUI一样,项目入侵量小,仅需要在Startup中注入的UI组件目前完成了第二个版本,1.增加本地json持久化调度任务,无需数据库2.增加直接调用本地类方法,无需通过WebAPI接口.本篇主要是介绍一下这两个新增的功能. 正文一.增加本地json...

收录时间: 2021-12-30
分类: .NET Core
贡献者: Rector
1376 热度

浅析.netcore中的Configuration

不管是.net还是.netcore项目,我们都少不了要读取配置文件,在.net中项目,配置一般就存放在web.config中,但是在.netcore中我们新建的项目根本就看不到web.config,取而代之的是appsetting.json。新建一个webapi项目,可以在startup中看到一个IConfiguration,通过框架自带的IOC使用构造函数进行实例化,在IConfiguration中我们发现直接就可以读取到appsetting.json中的配置项了,如果在控制器中需要读取配置,也是直接通过构造函数就可以实例化IConfiguration对象进行配置的读取。下面我们试一下运行的...

收录时间: 2021-12-27
分类: .NET Core
贡献者: Rector
1189 热度

Optimistic Concurrency in an HTTP API with ETags & Hypermedia

How do you implement optimistic concurrency in an HTTP API? There are a couple of different ways, regardless of what datastore you’re using in the backend. You can leverage the ETag header in the HTTP Response to return a “version” of the resource that was accessed. When a client then needs to perform some operation on the resource, they send an If-Match header apart of the request with the value being the result of ETag from the initial GET request. Another option is to leverage hypermedia by returning URIs for actions relevant to a resource that include the version apart of the URI. This enables concurrency to be completely transparent and does not require any knowledge from the client.

收录时间: 2021-12-16
分类: .NET Core
贡献者: Rector
AD 友情赞助
1107 热度

Finding Async Method Calls Missing Await

I’ve run into this issue not only when migrating legacy projects to use async/await in C# .NET, but even just day to day on greenfields projects. The issue I’m talking about involves code that looks like so

收录时间: 2021-12-13
分类: .NET Core
贡献者: Rector
1241 热度

Custom JSON Serialisation with System.Text.Json Converters

In this post, I want to cover one of the more complex concepts I’ve had to handle regarding serialisation; aggregations.

收录时间: 2021-12-13
分类: .NET Core
贡献者: Rector
1519 热度

YARP+AgileConfig 5分钟实现一个支持配置热更新的代理网关

YARP 是微软开源的一个反向代理项目,英文名叫 Yet Another Reverse Proxy 。所谓反向代理最有名的那就是 nginx 了,没错 YARP 也可以用来完成 nginx 的大部分功能,比如根据不一样的域名代理到不一样的后端服务上。既然它可以做反向代理,那么其实也就可以做服务网关了,类似 Ocelot ,当然缺少部分功能,比如限流降级等。Anyway ,今天先来体验一下。运行 YARPYARP 使用起来非常简单,它只是一个类库而已。我们新建一个 ASP.NET Core 的空网站。然后使用 nuget 安装 Yarp.ReverseProxy 。Install-Packag...

收录时间: 2021-12-12
分类: .NET Core
贡献者: Rector
1159 热度

An optimization story:–27% runtime costs for 8 lines of code

I give a lot of talks about performance and in those talks, I tend to emphasize the architectural impact of your choices. There is a huge tendency to focus on micro optimizations to get the performance you need, even though you can usually get orders of magnitude higher performance by making architectural changes.

收录时间: 2021-12-07
分类: .NET Core
贡献者: Rector
1354 热度

Upgrading a .NET 5 "Startup-based" app to .NET 6 Exploring .NET Core 6 - Part 12

In this short post I tackle a question I have received several times—"how can I update an ASP.NET Core 5 app that uses Startup to .NET 6's minimal hosting APIs"?

收录时间: 2021-12-01
分类: .NET Core
贡献者: Rector
AD 友情赞助