Hello everybody!

So, I'm trying to use linq to nhibernate and it's not really working
for me.

I'm trying to select the latest (top whatever) results from a table
and then group it by category.
The problem is that nh is first grouping and only the selects the top,
ignoring the order in the linq query.
I know I can split the two problems/queries to two different queries
but it's not a good solution because of the round-trip and a lot of
transport ( a lot of KB without the grouping ).

Someone?

The code looks like that:

var q = session.Linq<SomeEntity>()
                        .Where(x => x.UserId == userId)
                        .OrderByDescending(x => x.TimeStamp)
                        .Take(whatever)
                        .GroupBy(x => x.CategoryId)
                        .Select(x => new CategoryOccurences(x.Key, x.Count()));

And it should provide:

Select CategoryId, count(*) from
(
Select top whatever CategoryId
from SomeEntity
order by TimeStamp desc) sub_query
group by CategoryId




-- 
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.

Reply via email to