开发者

NHibernate 3.0 Linq Provider. Select not working after Skip and Top

Hi I use NHiberante to fill my web app's paged and ordered grid. It was working just fine until i decided to put projection in action.

This is the original, working code:

var data = repository
    .Where(predicate);
    .OrderBy(columns)
    .Skip(amount)
    .Take(anotherAmount);

Then I've started introducing my projection and it worked fine too:

var data = repository
        .Where(predicate);
        .OrderBy(columns)
        .Select(myProjection);

I was happy that everything works so I added 开发者_开发知识库missing Skip and Take, but stop - now Nhibernate states that Select is not supported (NotSupportedException). Code:

var data = repository
        .Where(predicate);
        .OrderBy(columns)
        .Skip(amount)
        .Take(anotherAmount)
        .Select(projection);

It's a bug or am I doing something wrong?


In my opinion this was a bug in NH. In 3.3.1.4000 version it works fine.


When you call .Count() you're executing the query, the query no longer exists. You need to issue two seperate queries to get the Count and List.

You can do something fancy with Future<> or MultiQuery.

Edit: http://groups.google.com/group/nhusers/browse_thread/thread/16c296414aedc09d

The second post on here should be able to point you in the right direction.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜