using Yw.DAL.PostgreSql;
|
|
namespace HStation.DAL.PostgreSql
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class PumpGroup : BaseDAL_Paras_Flags_TagName_Sorter<Entity.PumpGroup>, IPumpGroup
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; }
|
}
|
|
//删除拓展
|
public bool DeleteEx(long ID)
|
{
|
if (ID < 0)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var group = db.Queryable<Entity.PumpGroup>().ToList().Find(x => x.ID == ID);
|
var groupresult = db.Deleteable(group).ExecuteCommand() > 0;
|
if (!groupresult)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
var idlist = db.Queryable<Entity.PumpGroupAndMainMap>()
|
.Where(x => x.PumpGroupID == group.ID)
|
.Select(x => x.PumpMainID) // 假设 PumpGroupID 是与 PumpMain 关联的外键
|
.ToList();
|
var main = db.Queryable<Entity.PumpGroupAndMainMap>()
|
.Where(x => x.PumpGroupID == group.ID)
|
.ToList();
|
if (main.Count > 0)
|
{
|
var Modelresult = db.Deleteable(main).ExecuteCommand() > 0;
|
if (!Modelresult)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
var Map = db.Queryable<Entity.PumpMain>().ToList();
|
var Mapresult = db.Deleteable<Entity.PumpMain>()
|
.In(x => x.ID, idlist)
|
.ExecuteCommand() > 0;
|
if (!Mapresult)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
}
|
db.CommitTran();
|
return groupresult;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
}
|
}
|