Sounds like the same as http://groups.google.com/group/nhusers/browse_thread/thread/b29207ff1ac2cf1c?hl=en #
See if that's it and/or does help. Regards, *Mohamed Meligy *Readify | Senior Developer M:+61 451 835006 | W: readify.net [image: Description: Description: Description: Description: rss_16]<http://gurustop.net> [image: Description: Description: Description: Description: cid:[email protected]] <http://www.linkedin.com/in/meligy> [image: Description: Description: Description: Description: cid:[email protected]] <http://twitter.com/meligy> <http://www.greatplacetowork.com.au/best/best-companies-australia.php><http://www.readify.net/AboutUs/NewsItem.aspx?id=10> On Sun, May 8, 2011 at 9:12 PM, Eliran Hezkia <[email protected]> wrote: > 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. > > -- 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.
