asp.net core+EF架构查询数据库时报错
Entities代码
[Table("Dictionary")]
[Serializable]
public partial class Dictionary
{
/// <summary>
/// 数据字典ID
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// 字典名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 字典编码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 数据类型
/// </summary>
public int? Type { get; set; }
/// <summary>
/// 父级ID
/// </summary>
public Guid Pid { get; set; }
/// <summary>
/// 排序权重
/// </summary>
public int? Sort { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool Enabled { get; set; }
/// <summary>
/// 是否删除
/// </summary>
public bool Deleted { get; set; }
/// <summary>
/// 创建用户ID
/// </summary>
public Guid CreateId { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public DateTime? CreateTime { get; set; }
/// <summary>
/// 更新用户ID
/// </summary>
public Guid UpdateId { get; set; }
/// <summary>
///更新日期
/// </summary>
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
上下文代码
public class EntityDbContext : DbContext
{
public EntityDbContext(DbContextOptions options) : base(options)
{
}
public DbSet<Category> Categories { get; set; }
public DbSet<SysUser> SysUsers { get; set; }
public DbSet<SysUserToken> SysUserTokenes { get; set; }
public DbSet<SysUserLoginLog> SysUserLoginLogs { get; set; }
public DbSet<SysUserRole> SysUserRoles { get; set; }
public DbSet<SysPermission> SysPermissions { get; set; }
public DbSet<Dictionary> Dictionaries { get; set; }
}
调用代码
private IRepository<Entities.Dictionary> _dictionaryRepository;
private IHttpContextAccessor _accessor;
public DictionaryService(IRepository<Entities.Dictionary> dictionaryRepository, IHttpContextAccessor accessor)
{
this._dictionaryRepository = dictionaryRepository;
this._accessor = accessor;
}
/// <summary>
/// 获取所有数据字典并缓存
/// </summary>
/// <returns></returns>
public List<Entities.Dictionary> getAll()
{
var result = _dictionaryRepository.Table.Where(o => !o.Deleted);
var ex = result.Expression;
//result = result.Where(o => o.Code == "KGJ-2019-T-001" || o.Code == "KGJ-2019-T-002");
//return result.OrderBy(o => o.Type).ThenBy(o => o.CreateTime).ToList();
throw new NotImplementedException(ex.ToString());
}
报错问题: