tags:

views:

41

answers:

1

I have a situation where I definitely don't want to get the whole domain object. Basically, the entity has a primary key of long (.NET)/bigint(sql server 2005). I simply need to pass the primary key to an external system which will access the database directly - and since the list of ids could be large, I don't want to rehydrate the entire domain object just to get the Id.

In linq2sql, I could accomplish this with a projection, but I am restricted to NHibernate 1.2.1.4000, which doesn't support Linq.

Is there a way to accomplish this using NHibernate 1.2.1.4000?

(I am open to using a named-query if that will work)

+1  A: 

ICriteria.SetProjection(IProjection p) is available in NHibernate 1.2.

You could also use HQL (in a named query or not) to do projections, e.g.: select id from Person where...

Mauricio Scheffer