abp - GetListAsync 正在返回记录,包括 IsDeleted 为 true
问题描述
我有一个继承 ISoftDelete 的实体模型。当我使用 DeleteAsync 删除记录时,ABP 将 IsDeleted 成功设置为 true。
但是使用 GetListAsync 时会返回软删除的记录。
使用 ABP 2.8。
using Volo.Abp;
using Volo.Abp.Domain.Entities;
namespace POC.DataModels
{
public partial class Employee : Entity<int>, ISoftDelete
{
protected Employee()
{
}
public Employee(int id)
: base(id)
{
}
public string Name { get; set; }
public bool IsDeleted { get; set; }
}
}
using System.Collections.Generic;
using System.Threading.Tasks;
using POC.DataModels;
using Volo.Abp.Domain.Repositories;
namespace POC
{
public class EmployeeService : PocAppService
{
private readonly IRepository<Employee> _employeeRepository;
public EmployeeService(IRepository<Employee> employeeRepository)
{
_employeeRepository = employeeRepository;
}
public async Task<IReadOnlyList<Employee>> GetAllEmployeesAsync()
{
return await _employeeRepository.GetListAsync().ConfigureAwait(false);
}
public async Task DeleteEmployeeAsync(int employeeId)
{
await _employeeRepository.DeleteAsync(x=>x.Id == employeeId).ConfigureAwait(false);
}
}
}
解决方案
推荐阅读
- codenameone - 使用代号一的文本输入期间的基本文本格式
- node.js - 使用 nodejs 将文件复制到 NFS NAS,读/写流包含在 promise 中
- android-studio - Android Studio 模拟器没有正确显示颜色
- mongodb - 尝试从 RedHAt Linux 运行 mongodb-compass 时找不到 libgtk-3.so.0
- linux - 在 LINUX/BASH 中另一个文件的特定行号处插入文件内容
- nativescript - 使用底部导航导航时会弹出 radautocomplete 菜单
- arrays - MongoDB客户端加入多个集合
- java - 如何以编程方式隐藏 Android 操作栏上的菜单?
- django - 弹性豆茎没有创建超级用户,语法无效
- visual-studio-code - VS Code Java 编程缺少“源操作”上下文菜单