I should add that in this case, I don't have the inverse property (IList<Itinerary> Itineraries on Activity) on my other class. If I did, then the auto-mapper would make a many-to-many for me. I have no reason to ever need or want the inverse property on the other object, and I don't really want to clutter up my object model with it. Hence, the attribute idea.
On Mar 16, 12:37 pm, Jon Kruger <krugs...@gmail.com> wrote: > James (and company), > > Currently if I want to auto-map many-to-many collections using the > auto-mapper, I have to create an override class so that it knows that > it's a many-to-many and not a one-to-many, like this: > > public class Itinerary : Entity > { > private IList<Activity> _activities; > > public Itinerary() > { > _activities = new List<Activity>(); > } > > public virtual IList<Activity> Activities > { > get { return _activities; } > set { _activities = value; } > } > } > > public class ItineraryMappingOverride : > IAutoMappingOverride<Itinerary> > { > public void Override(AutoMap<Itinerary> mapping) > { > mapping.HasManyToMany(x => x.Activities); > } > } > > I think it would be nice if I could put an attribute on my collection > to do this for me, so that my code might look like this: > > public class Itinerary : Entity > { > private IList<Activity> _activities; > > public Itinerary() > { > _activities = new List<Activity>(); > } > > [AutoMapAsManyToMany] > public virtual IList<Activity> Activities > { > get { return _activities; } > set { _activities = value; } > } > } > > I don't know if you wanted to clutter things up with attributes or not > but I think it would make it easier (one attribute vs. having to > create an entire override class). If you'd like I can implement it > and send you a patch, it looks like all I would have to is add another > auto-mapping rule class and then tweak the AutoMapOneToMany rule to > ignore properties with the attribute. > > Jon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@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 -~----------~----~----~----~------~----~------~--~---