1.1 not honoring property conventions when the property is part of a CompositeId.

Original Post Ross Beehler's Avatar

Ross Beehler

24 May, 2010 03:22 PM via web

I have a CompositeID as follows:

        CompositeId()
            .KeyProperty(x => x.A, "A")
            .KeyProperty(x => x.SomeEnum, "SOME_ENUM");

I have a convention as follows:

public class SomeEnumTypePropertyConvention : IPropertyConvention, IConventionAcceptance<IPropertyInspector>
{
    public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
    {
        criteria.Expect(x => x.Property.PropertyType == typeof(SomeEnumType));
    }

    public void Apply(IPropertyInstance instance)
    {
        instance.CustomType<SomeEnumType>();
    }
}

With 1.0 installed, this convention worked on both regularly mapped properties and those used in CompositeId. With 1.1, it no longer works for those properties mapped in the CompositeId, and I don't see a workaround (note that I have to do the above to make NHibernate persist the int and not the ToString of the enum ... a better way to do that would also be appreciated).

Is this an intended change or a bug?

Ross

  1. Support Staff 2 Posted by Paul Batum on 05 Jun, 2010 09:59 AM

    Paul Batum's Avatar

    Without the convention you can do it like this:

                CompositeId()
                    .KeyProperty(x => x.Code)
                    .KeyProperty(x => x.CompanyType, kp => kp
                        .ColumnName("COMPANY_TYPE")
                        .Type(typeof(int)));

    I'm not sure what you should use if you want to achieve it with a
    convention. There's an IKeyPropertyConvention interface but it doesn't look
    like you can set the type using it at the moment.

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What is 4 times four?

    Recent Discussions

    05 Jul, 2010 10:29 PM
    05 Jul, 2010 12:45 PM
    05 Jul, 2010 12:42 PM
    05 Jul, 2010 12:17 PM
    05 Jul, 2010 12:12 PM

     

    03 Jul, 2010 12:26 AM
    02 Jul, 2010 02:17 PM
    02 Jul, 2010 08:18 AM
    02 Jul, 2010 12:20 AM
    01 Jul, 2010 10:14 PM