Not with anonymous type but with a real Type or a IList<object[]> 1)select e.Key, sum(e.Amount) from Entry e group by e.Key 2)select new YourStatisticEntry(e.Key, sum(e.Amount)) from Entry e group by e.Key 3) using 1 with a results trasformer to transform each result or the entirely IList.
2009/5/28 Chris Nicola <[email protected]> > 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 > > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
