Value Objects in C#
In this article, we are going to dive into a very interesting concept in domain-driven design: value objects. We will take a look at many aspects of value objects, what makes them useful, and discuss situations where they may not be appropriate.
Announcing C# Dev Kit for Visual Studio Code
We are thrilled to announce the preview release of C# Dev Kit, a new Visual Studio Code extension that brings an improved editor-first C# development experience to Linux, macOS, and Windows. The C# Dev Kit is designed to enhance your C# productivity when you’re working in VS Code. It works together with the C# extension, which has been updated to be powered by a new fully open-source Language Server Protocol (LSP) host, creating a performant, extensible, and flexible tooling environment that easily integrates new experiences into C# for VS Code. The source repo for this extension is in the process of being migrated and will be available later this week.
Should We Use Records With EF Core as Model Classes?
In this article, we will explore the pros and cons of using records with EF Core as model classes. We’ll dive into what C# records are, how they differ from classes, and how they can be used as model classes in EF Core.
EF Core + MySQL 基本增删改查
基于EF Core + MySQL的基本增删改查,示例是基于.NET6 + EF Core + MySQL 创建实体和数据库、EFCore 数据迁移项目基础上的内容增加。同时也是对基于Canal实现MySQL 8.0 数据库数据同步项目的验证。创建控制器Controllers---->添加---->控制器,选择api---->包含读写操作的API控制器。依赖注入将上下文类注入到UsersController中,ASP.NET Core 支持依赖关系注入 (DI) 软件设计模式,这是一种在类及其依赖关系之间实现控制反转 (IoC) 的技术。有三种具体实现方式,我们这里用到的是构造函数注入...
.Net全网最简RabbitMQ操作【强烈推荐】
本文自1年前的1.0版本推出以来,已被业界大量科技公司采用。同时也得到了.Net圈内多位大佬的关注+推荐,文章也被多家顶级.Net/C#公众号转载。现在更新到了7.0版本,更好的服务各位.Neter。 【正文】支持.Net/.Net Core/.Net Framework,可以部署在Docker, Windows, Linux, Mac。RabbitMQ作为一款主流的消息队列工具早已广受欢迎。相比于其它的MQ工具,RabbitMQ支持的语言更多、功能更完善。 本文提供一种市面上最/极简单的使用RabbitMQ的方式,只需要会调用以下三个方法,你就几乎可以掌握整个RabbitMQ的使用:...
URI Encode and Decode in .NET
In this article, we are going to learn about URI encode and decode and how we can achieve this using .NET. Only certain characters are valid in a URL. We therefore sometimes need to perform a URI encode and decode on some characters, before we transmit them over the internet and we call this process URI Encoding. We can classify characters in a URL as either reserved or unreserved. The reserved characters are those characters that have a special meaning and generally mark the various parts of a URL. For example, the ‘?‘ character in a URL indicates the start of any query parameters.
Visual Studio 2022 - 17.6 Now Available
In the sprint to the BUILD 2023 conference, we’re thrilled to announce the general availability of Visual Studio version 17.6 today. This latest release delivers a range of powerful tools and features designed to empower you in crafting cutting-edge applications and experiences. The user-friendly environment, along with essential features like code completion, debugging, refactoring, and version control, caters to both experienced and novice developers striving to achieve their software development objectives, solidifying its position as the go-to IDE for millions of developers worldwide.
[MAUI]模仿网易云音乐黑胶唱片的交互实现
创建页面布局创建手势控件创建影子控件唱盘拨动交互唱盘和唱针动画项目地址用过网易云音乐App的同学应该都比较熟悉它播放界面。这是一个良好的交互设计,留声机的界面隐喻准确地向人们传达产品概念和使用方法:当手指左右滑动时,便模拟了更换唱盘从而导向切换歌曲的交互功能。今天在 .NET MAUI中我们来实现这个交互效果,先来看看效果:使用.NET MAU实现跨平台支持,本项目可运行于Android、iOS平台。创建页面布局项目模拟了网易云音乐的播放主界面,可播放本地音乐文件。使用MatoMusic.Core作为播放内核,此项目对其将不再赘述。请阅读此博文[MAUI 项目实战] 音乐播放器...
.NET Core MongoDB数据仓储和工作单元模式实操
上一章节我们主要讲解了MongoDB数据仓储和工作单元模式的封装,这一章节主要讲的是MongoDB用户管理相关操作实操。如:获取所有用户信息、获取用户分页数据、通过用户ID获取对应用户信息、添加用户信息、事务添加用户信息、用户信息修改、用户信息删除等实战教程。
由ASP.NET Core读取Response.Body引发的思考
前几天有群友在群里问如何在我之前的文章《ASP.NET Core WebApi返回结果统一包装实践》的时候有点疑问,主要的疑问点就是关于Respouse的读取的问题。在之前的文章《深入探究ASP.NET Core读取Request.Body的正确方式》曾分析过关于Request的读取问题,需要读取Response的场景同样经常遇到,比如读取输出信息或者包装一下输出结果等。无独有偶Response的读取同样存在类似的问题,本文我们便来分析一下如何进行Response的Body读取。使用方式我们在日常的使用中是如何读取流呢?很简单,直接使用StreamReader去读取,方式如下...
ASP.NET Core中如何限制响应发送速率(不是调用频率)
ASP.NET Core中有很多RateLimit组件,.NET 7甚至推出了官方版本。不过这些组件的主要目标是限制客户端访问服务的频率,在HTTP服务器崩溃前主动拒绝部分请求。如果请求没有被拒绝服务会尽可能调用资源尽快处理。现在有一个问题,有什么办法限制响应的发送速率吗?这在一些需要长时间传输流式数据的情况时很有用,避免少量请求耗尽网络带宽,尽可能同时服务更多请求。Tip本文节选自我的新书《C#与.NET6 开发从入门到实践》12.11 流量控制。实现方式偏向知识讲解和教学,不保证组件稳定性,不建议直接在产品中使用...
从 Newtonsoft.Json 迁移到 System.Text.Json
System.Text.Json 是 .NET Core 3 及以上版本内置的 Json 序列化组件,刚推出的时候经常看到踩各种坑的吐槽,现在经过几个版本的迭代优化,提升了易用性,修复了各种问题,是时候考虑使用 System.Text.Json 了。本文将从使用层面来进行对比。 System.Text.Json 在默认情况下十分严格,避免进行任何猜测或解释,强调确定性行为。比如:字符串默认转义,默认不允许尾随逗号,默认不允许带引号的数字等,不允许单引号或者不带引号的属性名称和字符串值。 该库是为了实现性能和安全性而特意这样设计的。Newtonsoft.Json 默认情况下十分灵活。 关于性能,参考 Incerry 的性能测试:.NET性能系列文章二:Newtonsoft.Json vs. System.Text.Json ,如果打算使用 .NET 7 不妨考虑一下 System.Text.Json。
Blazor 拖放上传文件转换格式并推送到浏览器下载
昨天有个小伙伴发了一个老外java编写的小工具给我,功能是转换西班牙邮局快递Coreeos express的单据格式成Amazon格式,他的需求是改一下程序为匹配转换另一个快递公司MRW格式到Amazon格式,然而我堂堂一个Blazor发烧友,怎么可能去反编译人家的java修改呢?必须直接撸一个Blazor的啊.分析需求原始MRW文件...
Multipart Form-Data in HttpClient with ASP.NET Core
In this article, we will learn what multipart requests are and how we can use them. Also, we will review examples of how to send data to remote servers using multipart form-data with HttpClient in ASP.NET Core.
What's enough Complexity for a Domain Model?
Should you be applying domain-driven design? Do you need a domain model? You might want to if you have a lot of complexity within your domain. I often get asked, “what is a lot of complexity?”. I’m going to provide an example by uncovering more and more complexity within a domain. And give a few different insights that should help you make the decision.
What is .NET, and why should you choose it?
.NET has changed a lot since we kicked off the fast-moving .NET open-source and cross-platform project. We’ve re-thought and refined the platform, adding new low-level capabilities designed for performance and safety, paired with higher-level productivity-focused features. Span
How to Get Formatted JSON in .Net Using C#
This article will examine how we can get a formatted JSON representation of our C# objects using two popular libraries – Json.NET and System.Text.Json.
.NET February 2023 Updates – .NET 7.0.3, .NET 6.0.14
Today, we are releasing the .NET February 2023 Updates. These updates contain security and non-security improvements. Your app may be vulnerableif you have not deployed a recent .NET update.You can download 7.0.3and 6.0.14versions for Windows, macOS, and Linux, for x86, x64, Arm32, and Arm64...
在C#&.NET Core(.NET 7)程序开发中使用Npgsql,Dapper,EF Core等不同方式连接和操作PostgreSQL数据库示例教程(推荐阅读)
PostgreSQL(又称Postgres)是如今使用最广泛的数据库之一。根据2022年Stack Overflow的调查,它是专业开发人员使用最多的数据库;在TechEmpower基准测试中是最快的数据库;同时也自称自己是最先进的开源数据库。有了这么多响亮的句号加持,作为开发者的,是否已对PostgreSQL蠢蠢欲动了呢?今天,我们将讨论如何将PostgreSQL与我们最喜欢的语言(C#)结合起来。虽然Postgres不是微软的第一方数据库,如SQL Server,但并不意味着在C#编程中不能使用它或者对它的支持不够。相反,在本文中,你将看到在C#如何使用不同方式来连接并操作Postgres...
.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...