nhibernateicriteriaqueryover

NHIbernate: Shortcut for projecting all properties?


I'm trying to generate SQL along the lines of:

SELECT 
  t.*, 
  SELECT (...)
FROM Title t
[trimmed]

using QueryOver

Title title = null;

var q = session
   .QueryOver(() => title)
   .Select(
      Projections.Alias(Projections.Property<Title>(t => t.Id), "Id"),
      Projections.Alias(Projections.Property<Title>(t => t.Name), "Name"),
      ....
      Projections.SubQuery(sq.Where(tt => tt.Id == title.Id))), "TopLevelGenre")
)
[code trimmed]

There are 15 properties in Title that I would like to project. Is there an easier way of doing it so that I don't have to project each property individually as I've started to do above?


Solution

  • I've discovered that as of NHibernate 3.2, this is not possible without manually enumerating all of the properties.