The typical approach would be:

class EntityA
{
  public void AddEntityB(Entity b)
  {
    this.EntityBList.Add(b);
    b.EntityA = this;
  }
}

I believe many people use this approach or something similar.

On Oct 2, 7:26 pm, antoschka <[EMAIL PROTECTED]> wrote:
> @ Fabio: So how would you approach the problem?
>
> On 2 Okt., 13:58, "Fabio Maulo" <[EMAIL PROTECTED]> wrote:
>
> > NH work as your DAL and don't play in your logical tier.
>
> > 2008/10/2 antoschka <[EMAIL PROTECTED]>
>
> > > Hi,
>
> > > I use one-to-many foreign keys in my entities. e.g. EntityA & EntityB
> > > - EntityB has a Property which references EntityA
> > > "<many-to-one name="EntityA " cascade="none" column="EntityA " not-
> > > null="true" />"
>
> > > - EntityA has a inverse bag which contains all EntityBs referencing to
> > > EntityA
> > > "<bag name="FkEntityB" inverse="true" lazy="true" cascade="all">
> > >      <key column="EntityA " />
> > >      <one-to-many class="[class], [assembly]" />
> > >    </bag>
>
> > > The whole thing works fine. The only problem I have is when I add a
> > > transient new EntityB which references EntityA, hhe bag will not be
> > > updated and I have to do it manually, by adding EntityB to the bag-
> > > Collection.
>
> > > How can this be done automatiaclly without making the new EntityB
> > > persistent?
>
> > > Tahnska in advance for your help antoschka
>
> > --
> > Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
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