0

Which convention should be used to alter column name of CompositeId().KeyReference(x=>x.Key,/*THIS PART*/) method? I have used all available conventions in FluentNHibernate.Conventions and still haven't found the answer.

Thanks in advance

Sadegh
  • 4,181
  • 9
  • 45
  • 78

1 Answers1

1

still not possible now (FNH 1.2), except with some reflection-magic

class CompositeKeyConvention : ICompositeIdentityConvention
{
    public void Apply(ICompositeIdentityInstance instance)
    {
        var columninspector = instance.KeyManyToOnes.First(k => k.Name == "Key").Columns.First();

        var columnmapping = (ColumnMapping)columninspector.GetType().GetField("mapping", BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic).GetValue(columninspector);

        columnmapping.Name = "mycolumnname";
    }
}
Sadegh
  • 4,181
  • 9
  • 45
  • 78
Firo
  • 30,626
  • 4
  • 55
  • 94
  • How can you change the type? I am trying to make enums use int. .KeyProperty(x => x.EnumKey, x => x.ColumnName("EnumKey").Type(typeof(EnumKeyType))) <-- I want to convention that. – BradLaney Jan 05 '12 at 00:18