namespace Yw.DAL.SQLite
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class BimfaceFileLabel : BaseDAL<Entity.BimfaceFileLabel>, IBimfaceFileLabel
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return ConfigHelper.SQLiteConnectionConfig; }
|
|
}
|
|
/// <summary>
|
/// 根据 BimfaceFileID 获取
|
/// </summary>
|
public List<Entity.BimfaceFileLabel> GetByBimfaceFileID(long BimfaceFileID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.BimfaceFileLabel>()
|
.Where(x => x.BimfaceFileID == BimfaceFileID)
|
.ToList();
|
}
|
}
|
|
/// <summary>
|
/// 更新 Content
|
/// </summary>
|
public bool UpdateContent(long ID, string Content)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Updateable<Entity.BimfaceFileLabel>()
|
.SetColumns(x => x.Content == Content)
|
.Where(x => x.ID == ID)
|
.ExecuteCommandHasChange();
|
}
|
}
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
public bool Save(long BimfaceFileID, List<Entity.BimfaceFileLabel> entityList)
|
{
|
if (BimfaceFileID < 1)
|
{
|
return false;
|
}
|
if (entityList != null && entityList.Count > 0)
|
{
|
var bimfaceFileIds = entityList.Select(x => x.BimfaceFileID).Distinct().ToList();
|
if (bimfaceFileIds.Count != 1 || bimfaceFileIds[0] != BimfaceFileID)
|
{
|
return false;
|
}
|
}
|
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var ids = new List<long>();
|
if (entityList != null && entityList.Count > 0)
|
{
|
foreach (var entity in entityList)
|
{
|
if (entity.ID < 1)
|
{
|
entity.ID = db.Insertable(entity).ExecuteReturnSnowflakeId();
|
if (entity.ID < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
else
|
{
|
var bol = db.Updateable(entity).ExecuteCommandHasChange();
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
ids.Add(entity.ID);
|
}
|
}
|
db.Deleteable<Entity.BimfaceFileLabel>().Where(x => x.BimfaceFileID == BimfaceFileID && !ids.Contains(x.ID)).ExecuteCommandHasChange();
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
|
}
|
}
|