The best place for this discussion is *not* here, but actually on 
http://groups.google.com/group/nhusers.  This mailing list is for the NHib devs.

And the answer to your question depends in part on your mappings.  Please post 
them on the nhusers list along with your question.

Cheers,
John

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of void*
Sent: 31 March 2010 11:20
To: nhibernate-development
Subject: [nhibernate-development] ICriteria: select different type then type of 
criteria

Howdy y'all,

supposed I have a simple scenario like this (and mappings are
correctly set up in *.hbm.xml):

public class Foo
{
        // id and so on omitted

        public virtual Bar BarRef { get; set; }
}

public class Bar
{
        // id and so on omitted

        public virtual string Name { get; set; }
}

With HQL I can do this:
select b from Foo f inner join f.BarRef b where b.Name = "1887"

Even though I'm starting at a Foo I can return a Bar. Is something
similar possible with ICriteria?
I tried this (and different stuff):

ISession session = GetSessionFromSomewhere();
ICriteria criteria =
                                session
                                        .CreateCriteria<Foo>()
                                        .CreateAlias( "BarRef", "b" )
                                        .Add( Expression.Eq( "b.Name", "1887" ) 
);

// BOOM
criteria.List<Bar>();

Searching the net I found no examples like that, neither in NHibernate
in Action...
Are ResultTransformers or Projection what I need?

Regards,
void*


-- 
To unsubscribe, reply using "remove me" as the subject.

Reply via email to