fluent-nhibernate icon indicating copy to clipboard operation
fluent-nhibernate copied to clipboard

Allow mapping columns by convention

Open chilversc opened this issue 12 years ago • 3 comments

When mapping an IUserType or an ICompositeUserType by convention there is no ability to specify defaults for the column names.

I would like to be able to do something like

public class DateTimeOffsetConvention : IPropertyConvention, IPropertyConventionAcceptance
{
    public void Accept (IAcceptanceCriteria<IPropertyInspector> criteria)
    {
        criteria.Expect (x => x.Type == typeof (DateTimeOffset));
    }

    public void Apply (IPropertyInstance instance)
    {
        instance.CustomType<DateTimeOffsetType> ();
        instance.Columns.Add ("Utc");
        instance.Columns.Add ("Offset");
    }
}

chilversc avatar Apr 25 '13 13:04 chilversc

You mean that default column names should be field names?

chester89 avatar Apr 25 '13 14:04 chester89

I meant property names

chester89 avatar Apr 25 '13 16:04 chester89

No, I think the current default strategy is fine, which is to take the names from the IUserType and generate "PropertyName_ColumnName", its just the defaults should be overridable by convention.

chilversc avatar May 02 '13 14:05 chilversc