具有复合 ID 的参考实体
实体 A 和实体 A 都B 的 id 是:
CompositeId().KeyProperty(x => x.Id).KeyProperty(x => x.Type);
而实体 B 应该引用实体 A(它具有 A 类型的属性“A”)。我尝试过:
References(x => x.A).Columns("AId", "Type");
尝试插入时,这给了我 IndexOutOfRange 异常,原因是“Type”属性被映射了两次。所以我补充道:
References(x => x.A).Columns("AId", "Type").Not.Update().Not.Insert();
这会导致 AId 始终为 NULL,因为它被定义为不被插入。我希望它是可插入和可更新的,而“类型”则不是。我该怎么做?
Both entity A & B's id are:
CompositeId().KeyProperty(x => x.Id).KeyProperty(x => x.Type);
While entity B should Reference entity A (it has a property "A" of type A). I tried:
References(x => x.A).Columns("AId", "Type");
Which gave me IndexOutOfRange exception when trying to insert, the reason was that the "Type" property was mapped twice. So I added:
References(x => x.A).Columns("AId", "Type").Not.Update().Not.Insert();
Which causes AId to always be NULL because it's defined not to be inserted. I want it to be insertable and updatable, while "Type" not to be. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论