using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace IStation.DAL
{
///
/// 测点映射
///
public class MonitorPointMapping : Entity.MonitorPointMapping
{
#region Path
///
/// 查询文件路径
///
private string GetFolderPath()
{
return FileHelper.GetVersionsPath();
}
#endregion
#region Get
///
/// 查询全部
///
public List GetAll()
{
var path = GetFolderPath();
var all = FileIdHelper.GetAll(path);
var entities = all?.ToList();
return entities;
}
///
/// 根据 ID查询
///
public Entity.MonitorPointMapping GetByID(long ID)
{
if (ID < 0)
return default;
var all = GetAll();
var entities = all?.ToList();
return entities?.Find(t => t.ID == ID);
}
///
/// 根据 ID集合查询
///
public List GetByIds(IEnumerable Ids)
{
if (Ids == null || Ids.Count() < 1)
return default;
var all = GetAll();
var entities = all?.Where(x => Ids.Contains(x.ID)).ToList();
return entities;
}
#endregion
#region Insert
///
/// 插入
///
public long Insert(Entity.MonitorPointMapping rhs)
{
if (rhs == null)
return default;
var path = GetFolderPath();
return FileIdHelper.Insert(path, rhs);
}
///
/// 批量插入
///
public bool Inserts(IEnumerable list)
{
if (list == null || list.Count() < 1)
return default;
var path = GetFolderPath();
return FileIdHelper.Inserts(path, list);
}
///
/// 插入并返回
///
public Entity.MonitorPointMapping InsertR(Entity.MonitorPointMapping rhs)
{
if (rhs == null)
return default;
var path = GetFolderPath();
var entities = FileIdHelper.InsertR(path, rhs);
return entities;
}
///
/// 批量插入并返回
///
public List InsertsR(IEnumerable list)
{
if (list == null || list.Count() < 1)
return default;
var path = GetFolderPath();
var entities = FileIdHelper.InsertRs(path, list);
return entities?.Select(x => x.ID).ToList();
}
#endregion
#region Update
///
/// 更新
///
public bool Update(Entity.MonitorPointMapping rhs)
{
if (rhs == null)
return default;
var path = GetFolderPath();
return FileIdHelper.Update(path, rhs);
}
///
/// 批量更新
///
public bool Updates(IEnumerable list)
{
if (list == null || list.Count() < 1)
return default;
var path = GetFolderPath();
return FileIdHelper.Updates(path, list);
}
#endregion
#region Delete
///
/// 根据 ID删除
///
public bool DeleteByID(long ID)
{
if (ID < 0)
return default;
var path = GetFolderPath();
var bol = FileIdHelper.DeleteByID(path, ID);
return bol;
}
///
/// 根据 ID集合删除
///
public bool DeleteByIds(IEnumerable Ids)
{
if (Ids == null || Ids.Count() < 1)
return default;
var path = GetFolderPath();
var bol = FileIdHelper.DeleteByIds(path, Ids);
return bol;
}
///
/// 删除
///
public bool Delete(Entity.MonitorPointMapping rhs)
{
if (rhs == null)
return default;
var path = GetFolderPath();
var bol = FileIdHelper.DeleteByID(path, rhs.ID);
return bol;
}
///
/// 批量删除
///
public bool Deletes(IEnumerable list)
{
if (list == null || list.Count() < 1)
return default;
var path = GetFolderPath();
var Ids = list.Select(x => x.ID).ToList();
var bol = FileIdHelper.DeleteByIds(path, Ids);
return bol;
}
///
/// 删除全部
///
public bool DeleteAll()
{
var path = GetFolderPath();
var bol = FileIdHelper.DeleteAll(path);
return bol;
}
#endregion
#region Cover
///
/// 批量覆盖
///
public bool Covers(IEnumerable list)
{
if (list == null || list.Count() < 1)
return default;
var path = GetFolderPath();
return FileIdHelper.Covers(path, list);
}
///
/// 批量覆盖并返回
///
public List CoversR(IEnumerable list)
{
if (list == null || list.Count() < 1)
return default;
var path = GetFolderPath();
return FileIdHelper.CoversR(path, list);
}
#endregion
}
}