tags:

views:

78

answers:

1

_session.CreateQuery("Select a.AuLname From Authors a Order By a.AuLname") .List();

I must be drawing a blank here...but I cannot figure out how to return a list of author last names using the session's CreateCriteria method. Getting a distinct list of last names is not a problem as I can use a projection. But that is not what I am trying to do here.

TIA...

JP

+1  A: 

Try this:

_session.CreateCriteria<Author>()
   .SetProjection(Projections.Property("AuLname"))
   .AddOrder(Order.Asc("AuLname"))
   .List();
Markus Dulghier
Thanks Markus. That quite didn't do it...but you gave me something to talk about. Projection was definitly it - and it makes sense since we are projecting something to the list. This worked:_session.CreateCriteria(typeof (Authors)) .SetProjection(Projections.Property("AuLname")) .AddOrder(Order.Asc("AuLname")) .List<string>();
Your answer prompted me to put up a quick whitepaper on my blog:http://johnvpetersen.com/?p=61