开发者

FluentNHibernate: Just another Mapping Question

开发者 https://www.devze.com 2023-04-04 11:33 出处:网络
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 ha

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

精彩评论

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

关注公众号