修改写入实体数据方法,实现异步写入

dep_wangsr
CaesarBao 5 months ago
parent 422d9ff842
commit 403efae2aa

@ -243,7 +243,7 @@ namespace Admin.Core.IRepository
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
int Add(TEntity model); Task<int> Add(TEntity model);
/// <summary> /// <summary>
/// 批量添加 /// 批量添加

@ -610,14 +610,23 @@ namespace Admin.Core.Repository
/// </summary /// </summary
/// <param name="entity"博文实体类</param /// <param name="entity"博文实体类</param
/// <returns</returns /// <returns</returns
public int Add(TEntity entity) public async Task<int> Add(TEntity entity)
{ {
var insert = _db.CopyNew().Insertable(entity); //var insert = _db.CopyNew().Insertable(entity);
//return insert.ExecuteReturnIdentity();
try
{
return await _db.Insertable(entity).ExecuteCommandAsync();
}
catch (Exception ex)
{
return 0;
}
return insert.ExecuteReturnIdentity();
} }
/// <summary /// <summary
/// 写入实体数据 /// 写入实体数据
/// </summary /// </summary

@ -253,8 +253,15 @@ namespace Admin.Core.Service
Plan_Date = DateTime.Now.ToString("yyyy-mm-dd"), Plan_Date = DateTime.Now.ToString("yyyy-mm-dd"),
IF_FLAG = 1, IF_FLAG = 1,
}; };
var result = _planRepository.Add(xl_plan); var result = await _planRepository.Add(xl_plan);
return true; if (result == 1)
{
return true;
}
else
{
return false;
}
} }
catch (Exception ex) catch (Exception ex)
{ {

Loading…
Cancel
Save