How to map composite-id with fluent nhibernate using an interface?

前端 未结 2 825
鱼传尺愫
鱼传尺愫 2021-01-20 10:32

I\'m trying to switch out .hbm mappings to fluent mappings and have a problem with the mapping of composite-ids and the usage of Interfaces

the Class lo

2条回答
  •  青春惊慌失措
    2021-01-20 11:02

    Try downloading NhGen from SourceForge. It reads database schemas and generates Fluent mappings and classes etc. While all the code might not be what you need, it should start you off in the right direction as it supports composite keys and represents them as separate classes off the main entity.

    I beleive it uses a syntax similar to

     CompositeId()
                .ComponentCompositeIdentifier(x => x.Key, "Namespace.Key, Assembly")
                .KeyProperty(x => x.Key.Id1, "Id1")
                .KeyProperty(x => x.Key.Id2, "Id2")
                .KeyProperty(x => x.Key.Id3, "Id3");
    

提交回复
热议问题