I think this should work ...
var moviesOnCDs =
s.QueryOver<MovieOnCd>()
.Select(Projections.Distinct(Projections.Property<MovieOnCd>(moc =>
moc.Movie)))
.List<int>();
-----Original Message-----
From: Macko
Sent: Wednesday, December 01, 2010 8:48 AM
To: nhusers
Subject: [nhusers] [NH3] QueryOver and distinct values
Hello,
Query Over in NH 3.0 is great but currently I can't handle one problem
- I don't know how to rewrite simple SQL query which returns only
distinct values from intersection table.
Let's say that I have movies database and intersection table called
MoviesOnCDs which contains 3 columns:
id - PK
id_movie - FK to movies table
id_cd - FK to cds table
Now I want to have a list with distinct movie ids from this table.
Easy huh?
<sql>
select distinct id_movie from moviesOnCds
</sql>
How to rewrite this using .QueryOver?
I have ended with this, but it doesn't return unique results:
<nh>
var moviesOnCDs =
QueryOver.Of<MovieOnCd>()
.Select(fnp => fnp.Movie.id);
</nh>
--
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.
--
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.