views:

15

answers:

0

Hi

I am having trouble with using NHibernate's Linq querying functionality when trying to page data in a silverlight application.

I have a DomainService with a method like:

[Query(ResultLimit = 50)]
public IQueryable<Category> GetCategories() 
{ 
    return _Session.Linq<Category>(); 
}

In the silverlight app, I am trying to page for example

var query = myDomainContext.GetCategoriesQuery().Skip(10).Take(10);
myDomainContext.Load(query,........)

It returns a list of 50 entries, not 10 entries (It still does the skip). That is, the ResultLimit, not the pageSize. If I remove the ResultLimit part of the Query attribute, I get the right result of 10.

Checking the generated NHiberante code constructs the query as: (modified for clarity)

select * from category limit 10,50 (resultLimit included)
select * from category limit 10,10 (result limit excluded)

Somehow, the lambda is not being processed properly between the service method and actual execution, in order to select the maximum between the pageSize and the limit. Using Microsoft's LinqToEntites does this.

Is there a way round this to override or intercept the contruction of the sql from linq query using the resultLimit attribute part?

Any body else having this issue? Or is there something I'm missing?

Kind Regards

LJ