为什么 NHibernate 的接口 IQueryOver<T> 的方法 "Where" 在一个上下文中可用,但在其他上下文中不可用?

Why NHibernate's interface IQueryOver<T>'s method "Where" available in one context, but in other's not?

这里是第一种情况

using (ISession session = NHibernateHelper.OpenSession())
{
    using (ITransaction transaction = session.BeginTransaction())
    {
        session.QueryOver<T>().Where() // all ok

    }
}

这是相同的界面,但在其他界面class

productRepository.ExecuteQuery(over =>
{
    IQueryOver<Product> inOtherContext = over;
    inOtherContext.Where // where method not exists
});

我确定命名空间没有问题。

这里的解决方案是使用稍微不同的界面

IQueryOver<Product, Product>

例如,我们可以在 16.5. Aliases:

的文档中看到它是如何工作的
Cat catAlias = null;

IQueryOver<Cat,Cat> catQuery =
    session.QueryOver<Cat>(() => catAlias)
    ....

勾选source code here

/// <summary>
/// QueryOver&lt;TRoot,TSubType&gt; is an API for retrieving entities by composing
/// <see cref="Criterion.Expression" /> objects expressed using Lambda expression syntax
/// </summary>
/// <remarks>
/// <code>
/// IList&lt;Cat&gt; cats = session.QueryOver&lt;Cat&gt;()
///     .Where( c =&gt; c.Name == "Tigger" )
///     .And( c =&gt; c.Weight > minWeight ) )
///     .List();
/// </code>
/// </remarks>
public interface IQueryOver<TRoot,TSubType> : IQueryOver<TRoot>
{
   ...