I understand there is no way we can guarantee conventions being
applied in a given order, but I was wondering if anyone has a better
way to accomplish this.

Essentially, 99% of our many-to-one references follow this convention:

instance.Column(instance.Property.Name + "Id");

However, we have one reference that doesn't (legacy data model = no
choice here). So I thought I'd just implement an IPropertyConvention:

if (instance.Property.Name.Equals("LastModifiedBy"))
    instance.Column("LastModifiedPersonId");

After coding it I realized the mistake since I'm trying to override a
reference and not a property. (D'oh!)

So, I modified the reference convention:

instance.Property.Name.Equals("LastModifiedBy") ?
    instance.Column("LastModifiedPersonId") :
    instance.Column(instance.Property.Name + "Id");

This works, but I really don't like the implementation. Strings, for
one, conditional for another. If I find another m-1 that must be
overridden like this, I have to add another string and another
conditional (if then, case, whatever fits the bill).

Anyone run into something like this and have a better solution? Is
there any way, other than matching magic strings, that I can implement
an IReferenceConvention just for that one property (in effect, giving
me two implementations of IReferenceConvention)?

Cheers,

-devon

-- 
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