namespace Yw.DAL
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class HealthDeterioration : BaseDAL_Sorter<Entity.HealthDeterioration>
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return ConfigHelper.DefaultConnectionConfig; }
|
|
}
|
|
/// <summary>
|
/// 设置
|
/// </summary>
|
public bool Set(List<Entity.HealthDeterioration> list)
|
{
|
if (list == null || list.Count < 1)
|
return false;
|
var deductionList = list.Select(x => x.Deduction).Distinct().ToList();
|
if (deductionList.Count != list.Count)
|
return false;
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
|
//删除
|
var ids = list.Where(x => x.ID > 0).Select(x => x.ID).Distinct().ToList();
|
db.Deleteable<Entity.HealthDeterioration>().Where(x => !ids.Contains(x.ID)).ExecuteCommand();
|
|
foreach (var item in list)
|
{
|
if (item.ID < 1)
|
{
|
var id = db.Insertable(item).ExecuteReturnSnowflakeId();
|
if (id < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
else
|
{
|
var bol = db.Updateable(item).ExecuteCommandHasChange();
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
}
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
}
|
|
|
|
|
}
|
}
|