using Yw.DAL.SQLite;
|
|
namespace HStation.DAL.SQLite
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class AssetsPumpGroup : BaseDAL_Paras_Flags_TagName_Sorter<Entity.AssetsPumpGroup>, IAssetsPumpGroup
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return Assets.ConfigHelper.SQLiteConnectionConfig; }
|
}
|
|
//删除拓展
|
public bool DeleteEx(long ID)
|
{
|
if (ID < 0)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var group = db.Queryable<Entity.AssetsPumpGroup>().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.AssetsPumpGroupAndMainMapping>()
|
.Where(x => x.GroupID == group.ID)
|
.Select(x => x.MainID) // 假设 GroupID 是与 AssetsPumpMain 关联的外键
|
.ToList();
|
var main = db.Queryable<Entity.AssetsPumpGroupAndMainMapping>()
|
.Where(x => x.GroupID == 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.AssetsPumpMain>().ToList();
|
var Mapresult = db.Deleteable<Entity.AssetsPumpMain>()
|
.In(x => x.ID, idlist)
|
.ExecuteCommand() > 0;
|
if (!Mapresult)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
}
|
db.CommitTran();
|
return groupresult;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
}
|
}
|