历史数据库选择为sqlite时查询转换日期错误

This commit is contained in:
2248356998 qq.com
2023-04-05 18:04:33 +08:00
parent 75ef394eff
commit 1af9fd73ea
3 changed files with 7 additions and 4 deletions

1
.gitignore vendored
View File

@@ -363,6 +363,7 @@ MigrationBackup/
FodyWeavers.xsd
/src/ThingsGateway.Web.Server/Default.db
/src/ThingsGateway.Web.Server/Alarm_history.db
/src/PluginPro*/
/src/*Pro*
/src/TestResults*/

View File

@@ -5,7 +5,6 @@ using Furion.Logging.Extensions;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Concurrent;
using System.ComponentModel.DataAnnotations;
using System.Linq;
@@ -102,8 +101,11 @@ public class AlarmHostService : BackgroundService, ISingleton
{
SqlServerCodeFirstNvarchar = true,//设置默认nvarchar
TableEnumIsString = true,
}
},
});
return OperResult.CreateSuccessResult(sqlSugarClient);
}
#region worker服务

View File

@@ -146,8 +146,8 @@
var data = await result.Content.CopyNew().Queryable<AlarmHis>()
.WhereIF(!input.DeviceName.IsNullOrEmpty(), a => a.DeviceName.Contains(input.DeviceName))
.WhereIF(!input.Name.IsNullOrEmpty(), a => a.Name.Contains(input.Name))
.WhereIF(input.StartTime != null, a => a.EventTime >= input.StartTime)
.WhereIF(input.EndTime != null, a => a.EventTime <= input.EndTime)
.WhereIF(input.StartTime != null, a => a.EventTime >= input.StartTime.Value)
.WhereIF(input.EndTime != null, a => a.EventTime <= input.EndTime.Value)
.OrderByIF(!string.IsNullOrEmpty(input.SortField), $"{input.SortField} {input.SortOrder}")
.OrderBy(u => u.Id)//排序
.ToPagedListAsync(input.Current, input.Size);