Hello,

I'm exploring NH3 which is great but I'm stuck at creating simple
summaries.
I'm creating sample movie database.
I want to display every Movie entity with count of genres that is
associated with movie.
The output list should look like this:

MovieId | Title | Premiere | Genres Count
-----------------------------------------------------------------
3  | bla bla    | 1990-01-01    | 2

Using SQL it would look like this:

select f.*, isnull(fg.counter, 0) as genres_count
from dbo.movie f left join
(
select id_movie, count(id_genre) as counter
from dbo.movie_genres
group by id_movie
) fg on f.id = fg.id_movie

Now aggregation that counts genres for every movie using QueryOver:

GenreSummary alias = null;
var genresQuery = QueryOver.Of<MovieGenre>()
.SelectList(lista => lista
.SelectGroup(o => o.Film.Id).WithAlias(() => alias.MovieId)
.SelectCount(o => o.Genre).WithAlias(() => alias.GenresCount))
.TransformUsing(Transformers.AliasToBean<GenreSummary>());

Movie Query:

var movieQuery = QueryOver.Of<Movie>().ToList();

So now how to join genresQuery with movieQuery to create summary
entity list let's say MovieSummary? Can it be done with QueryOver?

--
Regards,
 Macko

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to