Not to bump this but I have yet to find a solution in Linq for this yet. I am trying to find an ideal way to do this using HQL or Criteria. Though perhaps a stored proc or something would be best?
Thanks, Chris On May 28, 11:59 am, Chris Nicola <[email protected]> wrote: > I was wondering if it is possible to do simple sums and groupings with > Linq2Nhibernate without returning the entire result set first using > .ToList(); > > My scenario: > > I have a table of accounts, and for each and every account I would like to > get a sum of transactions from three different tables. In SQL I would do > something like > > SELECT SUM(Amount), Account.id > FROM Entries > Group By Account.id > > In a Linq query I might try to return something like: > > from entry in session.Linq<Entry>() > group entry by entry.Account into list > select new > { > Account = list.Key, > Total = list.Sum(e => e.Amount) > > }; > > However that returns an error because nHibernate is expecting to return > entities of type <Entry> and not the anonymous type I just defined. > > Is there any way to get results like this? > > Thanks, > Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
