I answered your StackOverflow question on this too.
I think you need to use an alias to allow you to eager load the address,
something like:
var criteria = DetachedCriteria.For<Order>()
.CreateAlias("BillingContact", "bc")
.SetFetchMode("BillingContact", FetchMode.Eager)
.SetFetchMode("bc.Address", FetchMode.Eager)
On Wed, Feb 18, 2009 at 10:53 PM, Relleum <[email protected]> wrote:
>
> I have a hierarchy of objects, Order, Contact, Address.
>
> public class Order {
> public virtual Contact BillingContact { get; set; }
> }
>
> public class Contact {
> public virtual Address Address { get; set; }
> }
>
>
> I want to query an order by id, and eager load the billingcontact,
> along with it's address.
>
> var criteria = DetachedCriteria.For<Order>()
> .SetFetchMode("BillingContact", FetchMode.Eager)
>
> This criteria eager loads the billingcontact, but understandably not
> the address of the billingcontact. If i add:
> .SetFetchMode("BillingContact.Address", FetchMode.Eager)
>
> This does nothing to help.
>
> Also note that these relationships are unidirectional:
>
> public OrderMap()
> {
> References(x => x.BillingContact)
> .Not.Nullable()
> .Cascade.All();
> }
>
> public ContactMap()
> {
> HasOne(x => x.Address)
> .Cascade.All()
> .FetchType.Join();
> }
>
> public AddressMap()
> {
> Map(x => x.Address1);
> }
>
> How can I construct a criteria object that will load the child of the
> child? Do these relationship mappings seem correct?
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---