namespace Yw.DAL.SQLite { /// /// /// public partial class SysUnitValue : BaseDAL_Code_Sorter, ISysUnitValue { /// /// /// public override ConnectionConfig ConnectionConfig { get { return ConfigHelper.SQLiteConnectionConfig; } } /// /// 通过 TypeID 获取 /// public List GetByTypeID(long TypeID) { using (SqlSugarClient db = new(ConnectionConfig)) { return db.Queryable() .Where(x => x.TypeID == TypeID) .OrderBy(x => x.SortCode).ToList(); } } /// /// 通过 ID 删除(重写是为了清除关联的单位名称和单位转换) /// public override bool DeleteByID(long ID) { using (var db = new SqlSugarClient(ConnectionConfig)) { try { db.BeginTran(); var bol = db.Deleteable().Where(x => x.ID == ID) .ExecuteCommandHasChange(); if (!bol) { db.RollbackTran(); return false; } db.Deleteable().Where(x => x.ValueID == ID).ExecuteCommandHasChange(); db.Deleteable().Where(x => x.FromValueID == ID || x.ToValueID == ID).ExecuteCommandHasChange(); db.CommitTran(); return true; } catch { db.RollbackTran(); throw; } } } } }