摘要: 比如你要验证用户的时候判断一下这个用户名称在数据库是否已经存在了,这时候FluentValidation 就需要注入查询数据库 只需要注入一下就可以了 public class Login3RequestValidator : AbstractValidator<Login3Request> { p 阅读全文
posted @ 2022-08-14 12:05 Bo-Hong 阅读(91) 评论(0) 推荐(0) 编辑
摘要: FluentValidation.AspNetCore 引入包 public class Login2RequestValidator : AbstractValidator<Login2Request> { public Login2RequestValidator() { RuleFor(x = 阅读全文
posted @ 2022-08-14 11:57 Bo-Hong 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 如果一个方法内有多个写入操作,比如 写入A表,然后用A表的自增id 去写入B表,假如A表写入成功,但B表因为某种原因写入失败!(这就导致A表写入了脏数据) 这时候 我们可以自定义 一个Filter 进行拦截判断是否需要这个方法开启事务 using var txScope = new Transact 阅读全文
posted @ 2022-08-13 22:46 Bo-Hong 阅读(83) 评论(0) 推荐(0) 编辑
摘要: public class MyExceptionFilter : IAsyncExceptionFilter { private readonly ILogger<MyExceptionFilter> logger; private readonly IHostEnvironment env; pu 阅读全文
posted @ 2022-08-13 22:37 Bo-Hong 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 微软官网例子:Filter筛选器 使用场景(执行顺序): IAsyncActionFilter 使用异步actionFilter 只需要实现 他的 :OnActionExecutionAsync 方法 (注意这里的异步不是拦截异步是指的是 当前OnActionExecutionAsync方法内执行的 阅读全文
posted @ 2022-08-13 22:15 Bo-Hong 阅读(843) 评论(0) 推荐(0) 编辑
摘要: https://marketplace.visualstudio.com/items?itemName=SharpDevelopTeam.ILSpy#Overview 阅读全文
posted @ 2022-08-13 18:54 Bo-Hong 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 冒泡排序实际两种写法 for (int i = 0; i < arr.Length - 1; i++) { #region 将大的数字移到数组的arr.Length-1-i for (int j = 0; j < arr.Length - 1 - i; j++) { if (arr[j] > arr 阅读全文
posted @ 2022-08-12 16:53 Bo-Hong 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 调用: var ms = ExcelHelper.PrintInvoiceToExcel("观看时长", headline, items, (row, item) => { row.CreateCell(0).SetCellValue(item.Id.ToString()); row.CreateC 阅读全文
posted @ 2022-08-12 10:29 Bo-Hong 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 微软官方文档:ASP.NET Core 中的模型绑定 Route 是通过MVC Route URL取值。 如:http://localhost:5000/Home/Index/2,id取出的值就会是2。 Query 是通过URL Query参数取值。 如:http://localhost:5000/ 阅读全文
posted @ 2022-08-10 22:17 Bo-Hong 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 客户端发送消息 并接收服务端消息 package main import ( "fmt" "net" ) func main() { // conn, err := net.Dial(`tcp`, ":8848") if err != nil { fmt.Println(`net dial err: 阅读全文
posted @ 2022-08-10 21:34 Bo-Hong 阅读(64) 评论(0) 推荐(0) 编辑