This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Guys, Unsure how to get a group by to also sum over the groups. Say I have an entity with: [Id] [BossId] [AmmountOwed]
how do I do Select BossId, SUM(AmmountOwed) From entity where Id in x, y , z Group by BossId
Just can't work it out...
Thanks Owen |
|
|
I am guessing you are trying to achieve this using the underlying query API? If so, you cant perform this as a single query due to the limitations in the grouping functionality. The background on this is that because the grouping was largely implemented to support the LINQ provider, it is limited to dealing with direct entity properties (no aggregates or arbitrary projections) with a view that you would then issue subsequent queries to retrieve the sets of results you need. This works well for the LINQ provider where it always does need to issue subsequent queries to load the full set of entity properties in (and any possible eager loads etc) but it does present that restriction you are seeing around not being able to issue arbitrary single queries of that nature. Unfortunately for now thats the way it is and we do have an item on the backlog to improve this, but its not something that will be done in the near future at this stage. The other escape hatches are FindBySql or a stored proc.
Jeremy |
|
|
Thanks for the update Jeremy, I understand the limitations and I'll work round them, this just saves me trying too hard to get the querying to work in lightspeed
Thanks Owen |
|