摘要:var unitsTask = _basicDataService.GetUnitNamesAsync(); var documentTypesTask = _basicDataService.GetDocumentTypesAsync(); var organizationsTask = _bas
阅读全文
摘要:HttpClient 类型是在 2012 年发布的 .NET Framework 4.5 中引入的。 换句话说,它已经存在一段时间了。 HttpClient 用于从由 Uri 标识的网络资源发出 HTTP 请求和处理 HTTP 响应。 HTTP 协议占所有 Internet 流量的绝大部分。 根据推
阅读全文
摘要:/// <summary> /// Json序列化帮助类 /// </summary> public class JsonSerializerHelper { /// <summary> /// 将对象序列化为Json字符串(此Json序列化,是“不安全的放松JSON转义”,即不会将物特殊符号和中文
阅读全文
摘要:默认的 JsonConfigurationProvider 会按以下顺序加载配置: appsettings.json appsettings.{Environment}.json:例如,appsettings.Production.json 和 appsettings.Development.jso
阅读全文
摘要:常见工具类:https://www.easy-dotnet.com/
阅读全文
摘要:Visual Studio 常用快捷方式如下: 快速导航到文件或类型 Visual Studio 有一项称为“全部转到”的功能,可用于快速跳转到任何文件、类型、成员或符号声明。 若要从菜单栏中打开它,请选择“编辑”>“转到全部”>。 也可使用 Ctrl+T 键盘快捷方式打开它。 代码编辑器的右上方会
阅读全文
摘要:string? connectionString = builder.Configuration.GetConnectionString("DefaultConnection"); //Configuration.GetConnectionString("DefaultConnection"); S
阅读全文
摘要:.net AI 例子 AI:https://github.com/dotnet/ai-samples APS.NET CORE项目 https://learn.microsoft.com/zh-cn/aspnet/core/?view=aspnetcore-8.0 .net 开源项目 https:/
阅读全文
摘要:在 ASP.NET Core 中,后台任务作为托管服务实现。 托管服务是一个类,具有实现 IHostedService 接口的后台任务逻辑。 本文提供了三个托管服务示例: 在计时器上运行的后台任务。 激活有作用域的服务的托管服务。 有作用域的服务可使用依赖项注入 (DI)。 按顺序运行的已排队后台任
阅读全文
摘要:IActionResult 类型 当操作中可能有多个 ActionResult 返回类型时,适合使用 IActionResult 返回类型。 ActionResult 类型表示多种 HTTP 状态代码。 派生自 ActionResult 的任何非抽象类都限定为有效的返回类型。 此类别中的某些常见返回
阅读全文
摘要:标识API返回类型 [HttpGet("{id}")] [ProducesResponseType<Product>(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] public IAct
阅读全文
摘要:builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
阅读全文
摘要:检查 .NET Core 版本: dotnet --list-sdks
阅读全文
摘要:MediatR AutoMapper FluentValidation Entity Framework Core 8 ASP.NET Core 8 Fluent验证 下载 .Net 8
阅读全文
摘要:基础设施项目中集中添加依赖注入类: namespace CleanArchitectureApp.Infrastructure; public static class DependencyInjection { public static IServiceCollection AddInfrast
阅读全文
摘要:https://www.newtonsoft.com/json Product product = new Product(); product.Name = "Apple"; product.Expiry = new DateTime(2008, 12, 28); product.Sizes =
阅读全文
摘要:反射得到属于的值: var type = myTechs.GetType(); tech myTech = type.GetProperty(techName).GetValue(myTechs) as tech; 属于名:techName 设置 decimal 类型属性的精度 public cla
阅读全文
摘要:1 支持忽略循环引用 在 .NET 6 之前,如果 System.Text.Json 检测到循环引用,就会抛出 JsonException 异常。在 .NET 6 中,你可以忽略它们。 Category dotnet = new() { Name = ".NET 6", }; Category sy
阅读全文