Looks good to me!

On Sat, Dec 5, 2009 at 12:20 PM, Vladan Strigo <[email protected]> wrote:

> Ok, I think I did it...
>
> I created an attribute called "RelationParent"...that attribute I can
> put on any side of the relationship, on its property:
>
>        [Cascade(CascadeStyle.Delete)]
>        [RelationParent]
>        public virtual ISet<User> Users
>        {
>            get
>            {
>                return _users ?? (_users = new HashedSet<User>());
>            }
>            set
>            {
>                _users = value;
>            }
>        }
>        private ISet<User> _users;
>
>
> Then I created a ManyToManyTableNameConvention which has code like
> this:
>
>            if (otherSide.Member.HasAttribute<RelationParentAttribute>
> ())
>            {
>                return Inflector.Net.Inflector.Pluralize
> (otherSide.EntityType.Name)
>                     + Inflector.Net.Inflector.Pluralize
> (collection.EntityType.Name);
>            }
>
>            return Inflector.Net.Inflector.Pluralize
> (collection.EntityType.Name)
>                 + Inflector.Net.Inflector.Pluralize
> (otherSide.EntityType.Name);
>
>
> This way I can easily overwrite the behavior of automapping or simply
> be very specific as to how it will understand the relationship.
>
> Do you think that this is ok? Seems so far?
>
>
> Thanks!
> Vladan
>
> On 4 pro, 20:01, Vladan Strigo <[email protected]> wrote:
> > Ok, thnx for the answer...Ill try it out, to get a full grip on it,
> > Ill contact you if I cannot ;)
> >
> > Thnx again!
> >
> > Vladan
> >
> > On 4 pro, 00:16, James Gregory <[email protected]> wrote:
> >
> > > Rules are: If any table name is set in a convention or manually in the
> > > mapping on either side of the relationship, that name is used,
> > > otherwise the first mapping that FNH picks up will be considered the
> > > parent, and the other side the child.
> >
> > > If you want to control this naming, setup an automapping override for
> > > one side of the relationship and specify the table name for the
> > > HasManyToMany.
> >
> > > On 12/3/09, Vladan Strigo <[email protected]> wrote:
> >
> > > > I've been able to setup Automapping to map my many-to-manys great. It
> > > > works like a charm. :)
> >
> > > > However, I have a question...how does FNH decide when automapping
> > > > which table will it put as a Parent table (first in relation) and
> > > > which as Child table (second in relation)...
> >
> > > > Example...how does it decide that it will be ProductsToCustomers,
> > > > instead of CustomersToProducts?!
> >
> > > > Can this be changed (convention/override/attribute on class or
> > > > something)?
> >
> > > > Thanks!
> >
> > > > Vladan
> >
> > > > --
> >
> > > > 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]<fluent-nhibernate%[email protected]>
> .
> > > > 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<fluent-nhibernate%[email protected]>
> .
> 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 [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