Yes, if student -> user is a 1:1 relationship, you can do:

from s in session.Linq<Student>()
select new { s.Prop1, s.User.Prop1, s.User.Prop2 }

or if it is one-to-many:

from s in session.Linq<Student>()
from u in s.Users
select new { s.Prop1, u.Prop1, u.Prop2 }

As far as projecting the entire student entity along with specific
properties of a mapped association:

from s in session.Linq<Student>()
select new { s, s.User.Prop1, s.User.Prop2 }

That is not supported - again due to limitations with the Criteria API.

On Mon, May 4, 2009 at 12:04 PM, Action Jackson <[email protected]> wrote:

>
>
> Hi Chad,
>
>  Using the query technique you just specified, is there a way to
> project? The specific problem I'm trying to solve is to not have the
> entire User property be retrieved so that I don't have 20 extra,
> unnecessary parameters being retrieved in a select statement.  I'd
> like the equivalent of the following SQL query:
>
> select s.*, u.prop1, u.prop2 from student
> join user u on s.userid = u.userid
> where ....
>
> On May 4, 11:38 am, Chad Lee <[email protected]> wrote:
> > You can join on entity collections:
> >
> > from student in Session.Linq<Student>()
> > from user in student.Users
> > select user;
> >
> > if student has a collection of users.  Otherwise, yes, fall back to HQL.
> >
> >
> >
> > On Sun, May 3, 2009 at 5:33 PM, Action Jackson <[email protected]>
> wrote:
> >
> > >  Oh ok, fair enough.  Are there any workarounds that you would
> > > recommend? Or do I have to fall back to HQL?
> >
> > > On May 3, 5:25 pm, Fabio Maulo <[email protected]> wrote:
> > > > 2009/5/3 Chad Lee <[email protected]>
> >
> > > > > is not supported by the Criteria API with which the LINQ
> implementation
> > > is
> > > > > based.
> >
> > > > So far ;)
> >
> > > > --
> > > > Fabio Maulo- Hide quoted text -
> >
> > - Show quoted text -
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"NHibernate Contrib - Development Group" 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.ar/group/nhcdevs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to