Nice didn't realise I could do this:

var people = session.CreateCriteria(typeof (Person), "Person")
                    .CreateCriteria("Orders", "Order", JoinType.LeftOuterJoin)
                    .SetResultTransformer(Transformers.AliasToEntityMap)

.SetResultTransformer(Transformers.AliasToBean(typeof(PersonAndOrder)))
                    .List<PersonAndOrder>();

Works a charm.

Cheers

On Thu, Oct 16, 2008 at 9:39 PM, Gustavo Ringel
<[EMAIL PROTECTED]> wrote:
> You can set the projection to Person and Order and use
> AliasToBean(typeof(PersonAndOrder))...and then List<PersonAndOrder> and so
> you are done.
>
> Gustavo.
>
> On Thu, Oct 16, 2008 at 2:33 PM, Stefan Sedich <[EMAIL PROTECTED]>
> wrote:
>>
>> Now a real question on this say I have the following:
>>
>> var people = session.CreateCriteria(typeof (Person))
>>                    .CreateCriteria("Orders", "o", JoinType.LeftOuterJoin)
>>                    .SetResultTransformer(Transformers.AliasToEntityMap)
>>                    .List<IDictionary>();
>>
>> I can loop over to get my person and order and add to a class
>> PersonAndOrder, but is there a way to have it return
>> a List<PersonAndOrder> directly and easily without a loop?
>>
>>  foreach(IDictionary map in people) {
>>                var p = new PersonAndOrder {
>>                                                   Person =
>> map[CriteriaUtil.RootAlias] as Person,
>>                                                   Order = map["o"] as
>> Model.Order
>>                                           };
>>                peopleAndOrder.Add(p);
>> }
>>
>>
>> Yes doing this is dumb but my current test harness project has person
>> and order mapped and I use this harness for all testing :) so the
>> example might not be logical or make sense but the idea is there.
>>
>>
>> Thanks
>>
>> On Thu, Oct 16, 2008 at 8:48 PM, codemonkey <[EMAIL PROTECTED]>
>> wrote:
>> >
>> > Hello,
>> >
>> > Can someone put up a quick explination of how this is being acheived
>> > and what exactly it is doing?
>> >
>> >
>> > Thanks
>> > >
>> >
>>
>>
>>
>> --
>> Stefan Sedich
>> Software Developer
>> http://weblogs.asp.net/stefansedich
>>
>>
>
>
> >
>



-- 
Stefan Sedich
Software Developer
http://weblogs.asp.net/stefansedich

--~--~---------~--~----~------------~-------~--~----~
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