You know you can mix Query Over with Criteria, so you can use something
like:
var l =
session.QueryOver<Product>().Select(NHibernate.Criterion.Projections.Property<Product>(x
=> x.Name), NHibernate.Criterion.Projections.SqlProjection("case when price <
100 then 1 else 2 end as pricerange", new String[] { "pricerange" }, new
IType[] { NHibernateUtil.String })).List<Object[]>();
Will that do?
RP
On Thursday, May 2, 2013 10:16:52 AM UTC+1, PeteA wrote:
>
> I know this should be simple, but I seem to be being brain-dead today…
> given some entity Foo, how can I write a QueryOver that translates into the
> following SQL:
>
>
>
> select case
>
> when exists (select 1 from FooTable where Name='some
> name') then 1
>
> else 0
>
> end
>
>
>
> I.E. - I want to be able to determine in code if the entity already
> exists; counting them would be trivial, but I don't want to do that because
> there could be a lot and it's a significant amount of unnecessary work for
> the DB. The inner subquery is easy enough - how do I generate the outer
> query though, which doesn't have a 'from' statement?
>
>
>
> Thanks,
>
>
>
> /Pete
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.