I thinks you should do it in two calls. This is how most LINQ providers work
I think (f not all).
var query = from styles in session.Linq<Style>()
select styles;
totalCount = query.Count();
return query
.Skip((page-1) * recsPerPage)
.Take(recsPerPage)
.ToList();
Regards,
--
Mohamed Meligy
Senior Developer, Team Lead Backup (.Net Technologies) – Applications
Delivery - TDG
Injazat Data Systems
P.O. Box: 8230 Abu Dhabi, UAE.
Phone: +971 2 6992700
Direct: +971 2 4045385
Mobile: +971 50 2623624, +971 55 2017 621
E-mail: [email protected]
Weblog: http://weblogs.asp.net/meligy
On Fri, Nov 13, 2009 at 2:55 PM, Diego Mijelshon <[email protected]>wrote:
> I don't think you can use Futures with Linq, at least in this release.
> But your query can be easily represented with Criteria:
>
> var query = session.CreateCriteria(typeof(Style))
> .SetFirstResult((page-1) * recsPerPage)
> .SetMaxResults(recsPerPage)
> .Future<Style>;
> var count = session.CreateCriteria(typeof(Style))
>
> .SetProjection(Projections.Count(Projections.Id()))
> .FutureValue<int>;
>
> Diego
>
>
>
> On Tue, Nov 10, 2009 at 15:09, sk <[email protected]> wrote:
>
>>
>> Hello,
>>
>> I am using paging with L2N, everything works fine. However I also need
>> the total count of **all** rows. I would like to make 1 request only
>> though to the db. I found the following post from Ayende:
>>
>> http://ayende.com/Blog/archive/2009/04/27/nhibernate-futures.aspx
>>
>> My L2N looks very simple:
>>
>> var query = from styles in session.Linq<Style>()
>> select styles;
>>
>> return query
>> .Skip((page-1) * recsPerPage)
>> .Take(recsPerPage)
>> .ToList();
>>
>> Where would I implement FutureValue here?
>>
>> Thanks,
>>
>>
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---