using Yw.DAL.PostgreSql;
|
|
namespace HStation.DAL.PostgreSql
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class AssetsPumpMain : BaseDAL_Paras_Flags_TagName_Sorter<Entity.AssetsPumpMain>, IAssetsPumpMain
|
{
|
/// <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 main = db.Queryable<Entity.AssetsPumpMain>().ToList().Find(x => x.ID == ID);
|
var result = db.Deleteable(main).ExecuteCommand() > 0;
|
if (!result)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
var map = db.Queryable<Entity.AssetsPumpGroupAndMainMapping>().ToList().Find(x => x.MainID == ID);
|
if (map != null)
|
{
|
var mapresult = db.Deleteable(map).ExecuteCommand() > 0;
|
if (!mapresult)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
db.CommitTran();
|
return true;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
//插入拓展
|
public long InsertsEx(Entity.AssetsPumpMain AssetsPumpMain, Entity.AssetsPumpGroupAndMainMapping AssetsPumpGroupAndMainMap)
|
{
|
if (AssetsPumpMain == null)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var result = db.Insertable(AssetsPumpMain).ExecuteReturnSnowflakeId();
|
if (result < 0)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
if (AssetsPumpGroupAndMainMap != null)
|
{
|
AssetsPumpGroupAndMainMap.MainID = result;
|
var mapresult = db.Insertable(AssetsPumpGroupAndMainMap).ExecuteReturnSnowflakeId();
|
if (mapresult < 0)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
db.CommitTran();
|
return result;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
}
|
}
|