Hmm I thought that the type of the property has to match the type of
the private field exactly. But apparently having a property of type
IEnumerable<T> and a private field of type IList<T> works.

Thanks, great stuff :)


On Feb 18, 11:02 am, James Gregory <jagregory....@gmail.com> wrote:
> Why not return an IEnumerable instead of a copy of the list? That way the
> signature rather than the name of the property indicates the kind of actions
> they can take on it.
>
> On Thu, Feb 18, 2010 at 8:52 AM, adrianhara <adrian.h...@iquestint.com>wrote:
>
> > Hi guys,
>
> > Is it possible to map this?
>
> > class Foo
> > {
> >    private IList<Bar> bars;
>
> >    public IList<Bar> BarsCopy
> >    {
> >         get { return bars.ToList();}
> >    }
>
> >    public void AddBar(Bar newBar)
> >    {
> >        bars.Add(newBar);
> >    }
>
> >    public void RemoveBar(Bar bar)
> >    {
> >        bars.Remove(bar);
> >    }
> > }
>
> > Something like HasMany(x =>
> > x.Bars).Access.ReadOnlyPropertyThroughFieldNamed("bars") maybe?
>
> > Having the property named Bars instead of BarsCopy and using
> > ReadOnlyPropertyThroughLoweCaseField works, but I'd rather let users
> > of the class know that they get a copy so they don't abuse the
> > property. I'd even use a method instead of the property, but then, as
> > far as I read, there would be no way to map the private field with
> > fluentNH.
>
> > Thanks
>
> > --
> > 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