using System.Collections.Generic; using System.Linq; using FreeSql.DataAnnotations; using Mesnac.Action.ChemicalWeighing.FreeDb; namespace Mesnac.Action.ChemicalWeighing.AutoControl.DB { public class DeviceMaterrial { [Column(IsPrimary = true, IsIdentity = true)] public int Id { get; set; } /// /// 设备编号 /// public int DeviceId { get; set; } /// /// 对应物料的Id /// public int MaterrialId { get; set; } /// /// 1 干混机 2 糊化机 /// public int Type { get; set; } } public class DeviceMaterrialService { public void Save(List materrials) { var deviceMaterrial = materrials.First(); FreeSqlUnit.Instance.Delete() .Where(x => x.Type == deviceMaterrial.Type && x.DeviceId == deviceMaterrial.DeviceId) .ExecuteDeleted(); FreeSqlUnit.Instance.Insert(materrials).ExecuteAffrows(); } public List GetByTypeId(int type, int deviceId) { return FreeSqlUnit.Instance.Select() .Where(x => x.Type == type && x.DeviceId == deviceId) .ToList(); } } }