I didn't think about approaching it from the top down for the prefix
question but that makes sense. My first question:
ForTypesThatDeriveFrom<T>(Action<AutoMap<T>> populateMap,...
where as when you use the .Component method that's on the AutoMap
object it is
Component<T>(Func..., Action<ComponentPart<T>> action) which seems to
only use regular mapping instead of automapping since I have to supply
all my arguments to override any field.
.ForTypesThatDeriveFrom<Employee>(autoMap =>
{
autoMap.Map(p => p.JobTitle, "Title");
autoMap.Map(p => p.Salutation, "TitleOfCourtesy");
autoMap.Map(p => p.Phone, "HomePhone");
})
With this I don't need to supply .Map on every single property on my
Employee object but
autoMap.Component<Address>(p => p.Address, addr =>
{
addr.Map(c => c.Street, "Address");
addr.Map(c => c.State, "Region");
addr.Map(c => c.City, "City");
addr.Map(c => c.Country, "Country");
addr.Map(c => c.PostalCode, "PostalCode");
});
I do need to map every property.
There only seems to be a map component method and not an automap
component method, did that clear up my question?
On Feb 9, 6:07 am, James Gregory <[email protected]> wrote:
> > Should AutoMap.Component return down to Auto map for the component
>
> instead of just map so I don't need to have my redundant mappings
>
> I'm not quite sure what you mean here Chris.
>
> In the second one for <Order> is there anyway I can reach back up to
>
> convention.GetComponentColumnPrefix = type => string.Empty;
>
> There's not, but you could specify your convention to be something like
> this:
>
> convention.GetComponentColumnPrefix = property =>
> {
> if (property.PropertyType == typeof(Address) && property.DeclaringType ==
> typeof(Order))
> return "Ship";
> else
> return property.PropertyType.Name;
>
> };
>
> that's from memory, so it may not be exact, but you'd check the type that
> the property is declared in to see if it's Order, then override the column
> prefix.
>
> On Sun, Feb 8, 2009 at 9:59 PM, Chris Marisic <[email protected]> wrote:
>
> > In my AutoPersistanceModel setup I have this in my mapping
>
> > .ForTypesThatDeriveFrom<Customer>(autoMap =>
> > {
> > autoMap.Id(p =>
> > p.Id).GeneratedBy.Assigned().SetAttribute("length", "5");
> > autoMap.Map(p =>
> > p.CompanyName).Not.Nullable();
> > autoMap.Component<Address>(p
> > => p.Address, addr =>
>
> > {
>
> > addr.Map(c => c.Street, "Address");
>
> > addr.Map(c => c.State, "Region");
>
> > addr.Map(c => c.City, "City");
>
> > addr.Map(c => c.Country, "Country");
>
> > addr.Map(c => c.PostalCode, "PostalCode");
>
> > });
> > })
> > .ForTypesThatDeriveFrom<Order>(autoMap =>
> > {
> > autoMap.References(p =>
> > p.ShipVia, "ShipVia");
> > autoMap.Component<Address>(p =>
> > p.Address, addr =>
>
> > {
>
> > addr.Map(c => c.Street, "ShipAddress");
>
> > addr.Map(c => c.State, "ShipRegion");
>
> > addr.Map(c => c.City, "ShipCity");
>
> > addr.Map(c => c.Country, "ShipCountry");
>
> > addr.Map(c => c.PostalCode, "ShipPostalCode");
>
> > });
>
> > })
>
> > })
>
> > Should AutoMap.Component return down to Auto map for the component
> > instead of just map so I don't need to have my redundant mappings
>
> > addr.Map(x => x.City, "City");
> > addr.Map(x => x.Country, "Country");
>
> > In the second one for <Order> is there anyway I can reach back up to
> > convention.GetComponentColumnPrefix = type => string.Empty;
>
> > That I change that convention ForTypesThatDeriveFrom<Order> to "Ship" ?
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---