无法转换前pression型'NHibernate.IQueryOver< T,T>“返回类型“System.Linq.IQueryable< T>”类型、IQuery

2023-09-06 17:17:33 作者:心若在,梦就在

我敢肯定,我这样做不对,但我一直在捡了一段时间。我想实现一个IRepository查找方法,我只是似乎无法找出如何。任何帮助将大大AP preciated!

下面code给我用张贴问题的错误消息,红色波浪线。

 的IQueryable< T> IRepository< T> .Find(出pression< Func键< T,布尔>> predicate)
    {
        返回sessionManager.OpenSession()QueryOver< T>()式(predicate)。
    }
 

解决方案

您必须使用 .Query< T>()扩展方法,而不是

Java源码转C 源码的五款绝佳工具

I'm sure I'm doing this wrong, but I've been picking at it for a while. I'm trying to implement an IRepository Find method, and I just can't seem to work out how. Any help would be greatly appreciated!

The following code gives me the red squiggly line with the error message posted as the question.

   IQueryable<T> IRepository<T>.Find(Expression<Func<T, bool>> predicate)
    {
        return sessionManager.OpenSession().QueryOver<T>().Where(predicate);
    }

解决方案

You have to use .Query<T>() extension method instead.