tags:

views:

41

answers:

1

In other words how do you do something simple like this:

select 1

Or more specifically in the particular problem I'm dealing with, something like this:

SELECT (case when exists (<subquery>) then 1 else 0 end) AS result

So in short is there a way in NHibernate to do a select without having it generate the "FROM table" clause?

Thanks

+1  A: 

You are approaching this problem wrong.

Execute the subquery you are after using a count projection then do the if else logic in code.

Derek Ekins
Thanks for responding, derek. I wondered how quickly somebody would give me that answer :). Using count is actually the way I'm doing it now; I just thought a simple EXISTS would be a more efficient operation since no summing is involved. Thanks again.
Hmm I guess it would be more efficient, but there is no way of doing this with NHibernate short of executing the raw sql against the server. Probably not worth the performance/maintenance cost though.
Derek Ekins