Check out chapter 6.8 in the NHib docs on bi-directionals. You only need the
Orderline to contain the Order if you're looking to do a bi-directional. If
not, then there's no need. That chapter also explains why your problem went
away when you removed the Inverse() on the Order's HasMany mapping. An
inverse is only required on the "HasMany" side if it's going to be a
bi-directional reference.

On Sun, Apr 5, 2009 at 5:58 PM, depaulo <[email protected]>wrote:

>
> Oh my god I have just figured it out, but thought I should post this
> anyway just to help anyone else searching for this info as well.
> If you take the Inverse out of the HasMany mapping on the Order, then
> the foreign key is put into the OrderLine table without setting any
> back reference.
> How odd. But great at the same time :)
>
> On Apr 5, 11:56 pm, depaulo <[email protected]> wrote:
> > This is probably a daft question but I keep seeing contradictory info
> > on the internet and even in the nhib book.
> > If I have an Order with a IList<OrderLine> OrderLines {get; set;}
> > property and have the following in my mapping for Order:
> >             HasMany(x => x.OrderLines)
> >                 .AsList()
> >                 .Cascade.All()
> >                 .Inverse();
> >
> > Do I actually have to have the corresponding Order property on the
> > order line, have the Reference in the mapping in the OrderLineMapping
> > and code: orderline.Order = this; OrderLines.Add(orderLine) when
> > adding an order line?
> > If I do not do all this my foreign key field in OrderLine table is
> > always null.
> >
> > It makes sense that you would have to do this, but I see so many
> > examples on the net where people seem to be implying you only need to
> > do the bi-directional stuff if you actually want to navigate from an
> > OrderLine to an Order...
> >
> > A simple yes\no would be great!!!! Thanks everyone.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to