Jochen Jonckheere
unread,Oct 5, 2011, 4:07:09 AM10/5/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to fluent-n...@googlegroups.com
Hi,
I have a few entities that have an Address, in most of the classes they are mapped as component. This done via AutoMapping with:
public override bool IsComponent(Type type)
{
return type == typeof(Address);
}
But one of my entities now needs a collection of Addresses, AutoMapper doens't pick this up, so I made an override like this:
public class ConsultantMappingOverride : IAutoMappingOverride<Consultant>
{
public void Override(AutoMapping<Consultant> mapping)
{
mapping.HasMany(c => c.WorkAddresses)
.AsBag()
.Table("`ConsultantWorkAddress`")
.Component(c =>
{
c.Map(a => a.Street);
c.Map(a => a.HouseNumber);
...
});
}
}
In fact this seems to work, but now I have my Address automapped as component and I had to do it manually for the HasMany. Is there a better way?
Jochen