From 900895e375ecd94052132fc72187e6fea6a9e0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=99=E6=84=8F?= Date: Tue, 1 Apr 2025 11:28:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SqlServer=20=E4=B8=8B=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=87=BA=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.NET/Admin.NET.Core/Service/Log/SysLogMsgService.cs | 4 ++++ Admin.NET/Admin.NET.Core/Service/Log/SysLogOpService.cs | 4 ++++ Admin.NET/Admin.NET.Core/Service/Log/SysLogVisService.cs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Admin.NET/Admin.NET.Core/Service/Log/SysLogMsgService.cs b/Admin.NET/Admin.NET.Core/Service/Log/SysLogMsgService.cs index be61a011..e864f434 100644 --- a/Admin.NET/Admin.NET.Core/Service/Log/SysLogMsgService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Log/SysLogMsgService.cs @@ -68,6 +68,10 @@ public class SysLogMsgService : IDynamicApiController, ITransient { var _db = _sysLogMsgRep.AsSugarClient(); + // SqlServer 数据库,全局设置 IsWithNoLockQuery = true 时 Reportable 查询会报错 + // 通过禁用当前上下文的全局设置 Nolock,解决 Reportable 查询报错的问题 + _db.CurrentConnectionConfig.MoreSettings.IsWithNoLockQuery = false; + var now = DateTime.Now; var days = (now - now.AddYears(-1)).Days + 1; var day365 = Enumerable.Range(0, days).Select(u => now.AddDays(-u)).ToList(); diff --git a/Admin.NET/Admin.NET.Core/Service/Log/SysLogOpService.cs b/Admin.NET/Admin.NET.Core/Service/Log/SysLogOpService.cs index 9eaa3ee9..541fb8a8 100644 --- a/Admin.NET/Admin.NET.Core/Service/Log/SysLogOpService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Log/SysLogOpService.cs @@ -92,6 +92,10 @@ public class SysLogOpService : IDynamicApiController, ITransient { var _db = _sysLogOpRep.AsSugarClient(); + // SqlServer 数据库,全局设置 IsWithNoLockQuery = true 时 Reportable 查询会报错 + // 通过禁用当前上下文的全局设置 Nolock,解决 Reportable 查询报错的问题 + _db.CurrentConnectionConfig.MoreSettings.IsWithNoLockQuery = false; + var now = DateTime.Now; var days = (now - now.AddYears(-1)).Days + 1; var day365 = Enumerable.Range(0, days).Select(u => now.AddDays(-u)).ToList(); diff --git a/Admin.NET/Admin.NET.Core/Service/Log/SysLogVisService.cs b/Admin.NET/Admin.NET.Core/Service/Log/SysLogVisService.cs index 010d7851..c8c93f7d 100644 --- a/Admin.NET/Admin.NET.Core/Service/Log/SysLogVisService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Log/SysLogVisService.cs @@ -79,6 +79,10 @@ public class SysLogVisService : IDynamicApiController, ITransient { var _db = _sysLogVisRep.AsSugarClient(); + // SqlServer 数据库,全局设置 IsWithNoLockQuery = true 时 Reportable 查询会报错 + // 通过禁用当前上下文的全局设置 Nolock,解决 Reportable 查询报错的问题 + _db.CurrentConnectionConfig.MoreSettings.IsWithNoLockQuery = false; + var now = DateTime.Now; var days = (now - now.AddYears(-1)).Days + 1; var day365 = Enumerable.Range(0, days).Select(u => now.AddDays(-u)).ToList();