开发者

FluentNHibernate: Just another Mapping Question

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 开发者_Go百科in advance


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";
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜