1.1 not honoring property conventions when the property is part of a CompositeId.
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
Support Staff 2 Posted by Paul Batum on 05 Jun, 2010 09:59 AM
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.