开发者

Is it possible to call IQuerable.ToFuture() and IQuerable.Fetch() in same query for NHibernate (>3.0) Linq?

开发者 https://www.devze.com 2023-02-23 07:22 出处:网络
I want to use LINQ to NHibernate for a classic counting/pagination scenario: var query = Session.Query<Entity>().Where(...);

I want to use LINQ to NHibernate for a classic counting/pagination scenario:

var query = Session.Query<Entity>().Where(...);
var count = query.ToFutureValue(c => c.Count());
var results = query.OrderBy(x => x.Field)
                            .Skip(20)
                            .Take(10)
                            .Fetch(x => x.Related1)
                            .Fetch(x => x.Related2)
                            .ToFuture();

The core implementation of ToFutureValue() doesn't take an expression parameter, however this is very simple to implement (explained in this blog post). The last query fails with NotSupportedException("You can also use the AsFuture() method on NhQueryable") when calling .ToFuture() method. The problem seems to be that .Fetch() extension method returns an N开发者_JAVA百科hFetchRequest and the .Future() extension method expects and NhQuerable. Is there any workaround to this?

Edit: This bug was fixed in NHibernate Linq provider as of version 3.2


It's a bug/unsupported scenario. The error message is misleading.

You can open an issue at htt://jira.nhforge.org

The problem is with the fetch; it's not related to the FutureValue part.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号