I have tried using Criteria API and I hava the same result.

On Thu, Mar 2, 2017 at 1:52 PM, Felipe Oriani <[email protected]>
wrote:

> Ricardo, consider this code for countQuery. I'm using `Take` method:
>
> var total = countQuery.Select(Projections.RowCountInt64())
>                         .Take(250)
>                         .FutureValue<long>()
>                         .Value;
>
> On Thu, Mar 2, 2017 at 1:47 PM, Felipe Oriani <[email protected]>
> wrote:
>
>> Hi Ricardo, it is a paged query.
>> I'm using QueryOver. see the code bellow.
>> The countQuery object executes the query with subselect.
>>
>> var query = Session.QueryOver<T>();
>>
>> // aply filters on query
>>
>> var dataQuery = query.Skip(pageParameter.Skip)
>> .Take(pageParameter.Take)
>> .Future<TViewModel>();
>>
>> var countQuery = query.Clone();
>> countQuery.ClearOrders();
>>
>> var total = countQuery.Select(Projections.RowCountInt64())
>> .FutureValue<long>()
>>  .Value;
>>
>> var data = dataQuery.ToList();
>>
>> return new PagedList<TViewModel>(data, total);
>>
>> On Thu, Mar 2, 2017 at 12:32 PM, Ricardo Peres <[email protected]> wrote:
>>
>>> What are you using, LINQ?
>>> Have you tried Criteria API?
>>>
>>> RP
>>>
>>>
>>> On Thursday, March 2, 2017 at 3:20:38 PM UTC, Felipe Oriani wrote:
>>>
>>>> Hello guys,
>>>>
>>>> We have been using NHibernate in a project with Oracle database. We
>>>> have a count query that nhibernate is not returning what we want. The query
>>>> result:
>>>>
>>>> select
>>>> y0_
>>>> from (
>>>> SELECT
>>>> count(
>>>> *)
>>>> as y0_
>>>> FROM Table1 this_
>>>>            inner join ....
>>>>         where .... )
>>>>
>>>> where rownum <=250 /* :p3 */
>>>>
>>>>
>>>> The problem is that the count return more than 250 records. I would
>>>> like to count over the conditions of the main query limited a 250. If
>>>> NHibernate make a query like this:
>>>>
>>>>  SELECT count(*)
>>>>  FROM Table1 this_
>>>>       inner join ....
>>>>  where ....
>>>>  and rownum <=250
>>>>
>>>> Is there any way to avoid this subquery on the count?
>>>>
>>>> Thank you
>>>>
>>>>
>>>> --
>>>> ______________________________________
>>>> Felipe B Oriani
>>>> [email protected]
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "nhusers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/nhusers.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> ______________________________________
>> Felipe B Oriani
>> [email protected]
>>
>
>
>
> --
> ______________________________________
> Felipe B Oriani
> [email protected]
>



-- 
______________________________________
Felipe B Oriani
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to