我正在尝试实现一个通用存储库,如 https://codingblast.com/entity-framework-core-generic-repository/中所述
似乎通用 DbSet 没有实现 AsNoTracking() 方法,我没有使用正确的语法吗?如何解决此问题
public class BaseRepository<TEntity> : IGenericRepository<TEntity>
where TEntity : class
{
private readonly DbContext _dbContext;
public BaseRepository(DbContext dbContext)
{
_dbContext = dbContext;
}
public IQueryable<TEntity> GetAll()
{
return _dbContext.Set<TEntity>().AsNoTracking();
}
}