2011-04-18 153 views
0

能做到这一点流利nhibernate?复合键流利nhibernate

当我尝试保存时,我正在获取配置文件并且场景对象和ID不为空。

Nhibernate抱怨它无法为ProfileID列填充NULL。 Fluent Nhibernate不知道如何到达Profile.ID?

CompositeId().KeyProperty(x => x.Profile.ID, "ProfileID").KeyProperty(x => x.Scenario.ID, "ScenarioID"); 

回答

1

你应该使用这个代替:

CompositeId() 
    .KeyReference(x => x.Profile, "ProfileID") 
    .KeyReference(x => x.Scenario, "ScenarioID"); 
+0

是的,感谢科尔,是我最终发现了这一点。我不得不使用KeyReference来使映射工作。 – Erion 2011-05-03 19:30:18