Thanks for the feedback, Ayende!

It looks like you can create a sub-select under the where clause, but
not directly under the select statement. I worked around it by using a
join to get a count of notes not created by the user.

select
new AccountSummary (
         account.ID,
        account.Name,
        account.Balance,
        count(note)
)
from Account account
left join Account.Notes note
where account.Owner = :user
and (note is null or not note.User = :user)
group by account.ID, account.Name, account.Balance

I think this will get us what we need for now, but after reading about
MultiQueries, I can definitely see how it's gonna help out in some of
our future report queries.

Thanks again!


On Mar 22, 1:04 pm, Ayende Rahien <[email protected]> wrote:
> I _think_ it should just work this way.I would suggest using MutliQuery
> instead, though
>
>
>
> On Sat, Mar 21, 2009 at 5:24 PM, John Miller <[email protected]> wrote:
>
> > I have an Account entity that contains a Notes collection. I'd like to
> > create a "MyAccounts" screen that lists a few properties of each
> > account as well as a flag indicating if the account contains a note
> > that was submitted by someone other than the user running the query.
>
> > In a perfect world, I'd like to do something like this:
>
> > select
> > new AccountSummary (
> >                account.ID,
> >        account.Name,
> >        account.Balance,
> >        (
> >                select exists (from Notes note where note.Account = account
> > and not
> > note.User = :user
> >        )
> > )
> > from Account account
> > where account.Owner = :user
>
> > I know the "select exists" line is way off base, but I'm looking for a
> > solution that won't require me to return the entire list of notes. Is
> > this possible without resorting to straight Sql?
>
> > Any insight would be appreciated!- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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