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

dep_wangsr
CaesarBao 3 months ago
parent 422d9ff842
commit 403efae2aa

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

@ -610,14 +610,23 @@ namespace Admin.Core.Repository
/// </summary
/// <param name="entity"博文实体类</param
/// <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

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

Loading…
Cancel
Save