You cannot check whether the attribute has been set by another convention as you cannot guarantee the order the conventions are applied. This would work if you were setting the edge case in the mapping overrides. But again this is putting logic in the wrong place. The overrides are not convention overrides they are mapping overrides to fix or override mapping issues not handled by automapping. The fact that Email fields have a specific string length is a convention in its own right and should be stated as such.
-----Original Message----- From: fluent-nhibernate@googlegroups.com [mailto:fluent-nhibern...@googlegroups.com] On Behalf Of Berryl Hesh Sent: 17 April 2009 04:55 To: Fluent NHibernate Subject: [fluent-nhib] Re: conventions & overrides Rei That's exactly the sort of logic I was looking for (maybe without the magic "string" though). But, no, it doesn't work properly. Should it? Thx! Berryl On Apr 16, 9:22 am, Rei <rarol...@gmail.com> wrote: > Can you check if the "length" attribute has been set with the > HasAttribute method of the IProperty in the Accept method and only > return true if it has not been set? > > Something like > > public bool Accept(IProperty property) { > return property.HasAttribute("length"); > > } > > On Apr 16, 5:21 pm, Berryl Hesh <ef747...@gmail.com> wrote: > > > Please forgive me if the answer to this should be obvious from the > > docs. > > > I'm using AutoMapping w/ conventions, and I have an override class. > > The case I'm asking about happens to be re: StringLength but I'm > > hoping the idea should be applicable to any convention. > > > Convention class > > ------------------------ > > public class DefaultStringLengthConvention: IPropertyConvention > > { > > public bool Accept(IProperty property) { return true; } > > > public void Apply(IProperty property) { property.WithLengthOf > > (50); } > > } > > > Override > > ----------------- > > public void Override(AutoMap<User> mapping) { > > mapping.Map(x => x.Email).WithLengthOf(30); > > } > > > FNH looks at the override class before the convention, which explains > > why the generated ddl for Email.StringLength winds up being 50 instead > > of 30; so I'm guessing I need some logic in Accept() to deal with > > this. > > > Is that the case? > > > Thx! > > Berryl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---