Hi Richard,
Thanks for the quick reply. Taking the example below, I have managed
to make it work on my business model, but only by making sure the Tree
alias object is called the same as the list of trees in the Orchard
object itself.
Your below almost works, but I have to alter a couple of lines where
the alias is referenced:
Tree AppleTrees = null;
DetachedCriteria after =
DetachedCriteria.For<Orchard>()
.CreateAlias<Orchard>(o => o.AppleTrees, () =>
AppleTrees)
.SetFetchMode<Orchard>(o => o.AppleTrees,
FetchMode.Eager)
.SetFetchMode(() => AppleTrees.Fruit,
FetchMode.Eager);
Can you see any reason for this? It seems odd that I have to have a
variable with the same name, as its not really being used, other than
to get the name of the alias correct.
I assume that it is because nHibernate can't find anything called
treeAlias in the database, but don't see why it needs the alias to be
the same as the object.
Thanks
mark
On Mar 27, 12:47 pm, "Richard Brown \(GMail\)"
<
fluke...@googlemail.com> wrote:
> Hi Mark,
>
> The key thing is to figure out how you would do it without the extensions.
> I think you need to use an alias to do this in regular ICriteria using
> something like:
>
> DetachedCriteria before =
> DetachedCriteria.For<Orchard>()
> .CreateAlias("AppleTrees", "treesAlias")
> .SetFetchMode("AppleTrees", FetchMode.Eager)
> .SetFetchMode("treesAlias.Fruit", FetchMode.Eager);
>
> I think the extensions equivalent would be:
>
> Tree treesAlias = null;
> DetachedCriteria after =
> DetachedCriteria.For<Orchard>()
> .CreateAlias<Orchard>(o => o.AppleTrees, () =>
> treesAlias)
> .SetFetchMode<Orchard>(o => o.AppleTrees,
> FetchMode.Eager)
> .SetFetchMode(() => treesAlias.Fruit, FetchMode.Eager);
>
> Let me know if that works.
>
> Cheers,
> Richard
>
> --------------------------------------------------
> From: "markharrison" <
harrisonmeis...@gmail.com>