using Yw.DAL.SQLite;
namespace HStation.DAL.PBS.SQLite
{
///
/// 模型模板
///
public class ModelTemplate :BaseDAL_Paras_Flags_TagName_Sorter_UseStatus ,IModelTemplate
{
///
///
///
public override ConnectionConfig ConnectionConfig
{
get { return HStation.PBS.ConfigHelper.SQLiteConnectionConfig; }
}
///
/// 通过 GroupID 获取
///
public List GetByGroupID(long GroupID)
{
using (var db = new SqlSugarClient(ConnectionConfig))
{
return db.Queryable()
.Where(x => x.GroupID == GroupID).ToList();
}
}
///
/// 通过 GroupIds 获取
///
public List GetByGroupIds(List GroupIds)
{
if (GroupIds == null || !GroupIds.Any())
{
return default;
}
using (var db = new SqlSugarClient(ConnectionConfig))
{
return db.Queryable()
.Where(x => GroupIds.Contains(x.GroupID)).ToList();
}
}
///
/// 更新 GroupID
///
public bool UpdateGroupID(long ID, long GroupID)
{
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
{
return db.Updateable()
.SetColumns(x => x.GroupID == GroupID)
.Where(x => x.ID == ID)
.ExecuteCommand() > 0;
}
}
///
/// 批量更新 GroupID
///
public bool UpdateGroupIds(List<(long ID, long GroupID)> list)
{
if (list == null || list.Count < 1)
return false;
using (var db = new SqlSugarClient(this.ConnectionConfig))
{
var entityList = list.Select(x => new Entity.PBS.ModelTemplate() { ID = x.ID, GroupID = x.GroupID }).ToList();
return db.Updateable(entityList)
.UpdateColumns(nameof(Entity.PBS.ModelTemplate.GroupID))
.ExecuteCommandHasChange();
}
}
}
}