I usually do something like this:

public class Customer
{

  private IList<Order> _orders;

  public Customer()
  {
    _orders = new List<Order>();
  }

  public IEnumerable<Order> Orders { get { return _orders; } }

  public void AddOrder(Order o)
  {
     o.Customer = this;
     _orders.Add(o);
  }
}



On Tue, Jul 6, 2010 at 9:50 PM, mynkow <myn...@gmail.com> wrote:

> Component<EntitySet<DepartmentEntity>>( x => x.Departments, m =>
> { m.HasMany<DepartmentEntity>( Reveal.Member<EntitySet<DepartmentEntity>>(
> "_internalCollection" ) ).Access.Field() .KeyColumn( "DepartmentOrgId" )
> .ForeignKeyConstraintName( "FK_OrgDepartment" ).AsSet(); } );
>
> This is what I did after all. But I need some advices how to manage
> collections with NHibernate. Many people advice me to use ISet,
> IEnumerable, IList etc. for collections and avoid custom collections.
> And may be this is a good approach. But here is the question: Should I
> always use IEnumerable for my collections and if yes how to add new
> Items to the collection when adding an element will result to new
> IEnumerable collection? Can Nhibernate can keep track of the
> collection items in this situation? I do not know. I am so confused
> right now.
>
> On Jul 5, 2:47 pm, Paul Batum <paul.ba...@gmail.com> wrote:
> > Off the top of my head I would have though you could do something like:
> >
> > Component(x => x.Departments, c =>
> >    c.HasMany<DepartmentEntity>(Reveal.Member("_internalCollection"))
> >      .Table("DEPARTMENT")
> >      .Cascade.SaveUpdate
> >      .Access.Field
> >      .KeyColumn("DepartmentOrgId")
> >      .ForeignKey("FK_OrgDepartment")
> > );
> >
> > My syntax might be slightly off but I thought this would work... if not,
> can
> > you provide more detail on why?
> >
> > On Sun, Jul 4, 2010 at 3:35 PM, mynkow <myn...@gmail.com> wrote:
> > > Hi, I have troubles converting this xml mapping part to fluent. Please
> > > help me
> >
> > > <component name="Departments"
> >
> > >
> class="Core.Domain.Collections.EntitySet`1[Core.Domain.OrgStructure.IDepartmentEntity,BusinessWare.Core],Core">
> > >        <set name="_internalCollection" table="`DEPARTMENT`"
> > > cascade="save-update" access="field" generic="true" lazy="true" >
> > >          <key column="`DepartmentOrgId`" foreign-
> > > key="FK_OrgDepartment" />
> > >          <one-to-many
> > > class="Domain.Model.OrgStructure.DepartmentEntity,Domain"/>
> > >        </set>
> > >      </component>
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Fluent NHibernate" group.
> > > To post to this group, send email to
> fluent-nhibern...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com>
> <fluent-nhibernate%2bunsubscr...@googlegroups.com<fluent-nhibernate%252bunsubscr...@googlegroups.com>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/fluent-nhibernate?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-nhibern...@googlegroups.com.
> To unsubscribe from this group, send email to
> fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to