存储库模式中的管道和过滤器模式 returns“不包含 X 的定义...需要 IQueryable 类型的接收器<Y>

Pipe and Filter pattern in a Repository pattern returns "does not contain a definition for X... requires a receiver of type IQueryable<Y>

我正在尝试实现一个基本的管道和过滤器模式并在 LinqPad 5 中对其进行测试。

包含扩展方法的 class 如下所示:

public static class MyExtensions
{
    public static IQueryable<PortfolioSection> AreNotDeleted(this IQueryable<PortfolioSection> portfolioSections)
    {
        return portfolioSections.Where(portfolioSection => portfolioSection.IsDeleted == false);
    }
    
    public static int AddMe(this int number, int newNumber){
        return number + newNumber;
    }
}  

在 linqpad 的主要部分中,我执行以下操作:

void Main()
{
    PortfolioSections.AreNotDeleted().Dump();
}  

我也尝试添加 AsQueryable 以确认这不是问题所在:

void Main()
{
    PortfolioSections.AsQueryable().AreNotDeleted().Dump();
}  

在这两种情况下我都遇到了异常:

CS1929 'DbSet' does not contain a definition for 'AreNotDeleted' and the best extension method overload 'MyExtensions.AreNotDeleted(IQueryable)' requires a receiver of type 'IQueryable'

我正在关注这篇文章以了解有关管道和过滤器模式的更多信息,并且最初在我的 c# 项目中对此进行了尝试,但是当我发现我的查询结果在我包含时没有改变时切换到 LinqPad扩展方法 AndAreNotDeleted。在我的项目中,虽然没有异常,但另一方面,LinqPad 会抛出上述异常。

有什么地方出错了吗?

我在 Linpad 中的连接类型基于我项目的包含 DbContext 的持久性库。我最初在代表数据实体的所有域 类 中进行了复制,忘记了我只需要按 F4 并添加一个指向包含域 类 的库的 using 语句。这似乎已经解决了我在 Linqpad 中的所有问题,我现在可以实现该模式了。