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