views:

193

answers:

1

does anyone know if you can do something like this using the (N)Hibernate criteria api:

Select 1 AS obj.Property0, obj.Property1, obj.Property2 from Class

Baiscally I want to select a constant value for one of my properties in the query. I can do this easy enough using HQL but I was wondering if anyone knew a way using the criteria api?

+1  A: 

you can do this by using the SQLProjection:

projections.Add(Projections.SqlProjection("1 as PropertyName", new[] {"PropertyName"},
                                                          new IType[] {NHibernateUtil.Int32}));
lomaxx