2

It is possible to create ComponentConvention, but this code does not work because References collection is collection of IManyToOneInspector and not IManyToOneInstace. Is there any other way to specify column?

public class ComponentConvention : IComponentConvention
{
    public void Apply(IComponentInstance instance)
    {
        foreach (var inspector in instance.References)
        {
            inspector.Column("some_name");
        }
    }
}
xelibrion
  • 2,220
  • 1
  • 19
  • 24

1 Answers1

1

Sadly References aren't exposed in the same way as Properties and OneToOnes. You can access the underlying ComponentMapping with reflection and then create your own ManyToOneInstances with

var mapping = (ComponentMapping) typeof (ComponentInstance).GetField("mapping", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(instance);
foreach (var r in mapping.References)
{
    var ri = new ManyToOneInstance(r);
    ri.Column("some_name");
}
  • Thanks for workaround, but it introduces high probability of breaking changes in next version of FNH, so I would stay with overrides rather than using this convention. – xelibrion Aug 19 '11 at 07:54