using AutoMapper; using DMS.Core.Models; using DMS.Infrastructure.Interfaces; using DMS.Infrastructure.Entities; using System.Diagnostics; using DMS.Infrastructure.Data; namespace DMS.Infrastructure.Repositories; public class VarTableRepository : BaseRepository { public VarTableRepository(SqlSugarDbContext dbContext) : base(dbContext) { } /// /// 添加变量表 /// /// /// 变量表的ID public override async Task AddAsync(DbVariableTable entity) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var addVarTabel = await Db.Insertable(entity) .ExecuteReturnEntityAsync(); stopwatch.Stop(); //NlogHelper.Info($"添加变量表 '{entity.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms"); return addVarTabel; } /// /// 编辑变量表 /// /// /// public override async Task UpdateAsync(DbVariableTable entity) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var result = await Db.Updateable(entity) .ExecuteCommandAsync(); stopwatch.Stop(); //NlogHelper.Info($"编辑变量表 '{entity.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms"); return result; } /// /// 删除变量表 /// /// /// public override async Task DeleteAsync(DbVariableTable entity) { if (entity == null ) return 0; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // 转换对象 var res= await Db.Deleteable(entity) .ExecuteCommandAsync(); stopwatch.Stop(); //NlogHelper.Info($"删除变量表 '{entity.Name}' 耗时:{stopwatch.ElapsedMilliseconds}ms"); return res; } /// /// 删除变量表支持事务 /// /// /// public async Task DeleteAsync(IEnumerable deviceVariableTables) { if (deviceVariableTables == null || deviceVariableTables.Count() == 0) return; // 转换对象 await Db.Deleteable(deviceVariableTables) .ExecuteCommandAsync(); } }