Files
DMS/DMS.Infrastructure/Repositories/DeviceRepository.cs

41 lines
1.1 KiB
C#
Raw Normal View History

2025-07-03 13:53:29 +08:00
using System.Diagnostics;
using AutoMapper;
using DMS.Infrastructure.Entities;
using DMS.Core.Enums;
2025-07-19 09:25:01 +08:00
using DMS.Core.Helper;
using DMS.Core.Models;
using DMS.Infrastructure.Data;
using SqlSugar;
2025-07-19 11:11:01 +08:00
using DMS.Infrastructure.Interfaces;
2025-06-10 22:13:06 +08:00
namespace DMS.Infrastructure.Repositories;
2025-06-10 22:13:06 +08:00
public class DeviceRepository : BaseRepository<DbDevice>
2025-06-10 22:13:06 +08:00
{
2025-07-02 22:07:16 +08:00
public DeviceRepository(ITransaction transaction)
: base(transaction)
{
2025-06-10 22:13:06 +08:00
}
2025-07-02 22:07:16 +08:00
public override async Task<List<DbDevice>> GetAllAsync()
2025-06-10 22:13:06 +08:00
{
2025-07-03 13:53:29 +08:00
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
2025-07-19 11:11:01 +08:00
var dlist = await Db.Queryable<DbDevice>()
.Includes(d => d.VariableTables, dv => dv.Device)
.Includes(d => d.VariableTables, dvd => dvd.Variables, data => data.VariableTable)
.Includes(d => d.VariableTables, vt => vt.Variables, v => v.VariableMqtts)
.ToListAsync();
2025-07-04 18:33:48 +08:00
stopwatch.Stop();
2025-07-19 11:11:01 +08:00
NlogHelper.Info($"加载设备列表总耗时:{stopwatch.ElapsedMilliseconds}ms");
return dlist;
2025-07-04 18:33:48 +08:00
}
2025-07-19 09:25:01 +08:00
2025-06-10 22:13:06 +08:00
}