流畅的复合键Nhibernate [英] Composite keys fluent nhibernate
本文介绍了流畅的复合键Nhibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人能在流利的nhibernate上做到这一点吗?
Can one do this on a fluent nhibernate ?
当我尝试保存时,我正在提供个人资料和场景对象,并且ID不为空.
When I try to save, I am profiding the profile and the scenario objects and the id's are not null.
Nhibernate抱怨它不能为ProfileID列保证NULL.流利的Nhibernate不知道如何进入Profile.ID?
Nhibernate complains that it can't insurt NULL for ProfileID column. Fluent Nhibernate doesn't know how to get to the Profile.ID ?
CompositeId().KeyProperty(x => x.Profile.ID, "ProfileID").KeyProperty(x => x.Scenario.ID, "ScenarioID");
推荐答案
您可能应该改用它:
CompositeId()
.KeyReference(x => x.Profile, "ProfileID")
.KeyReference(x => x.Scenario, "ScenarioID");
这篇关于流畅的复合键Nhibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文