NHibernate 3.2 符合复合 id
我正在升级到 NHibernate 3.2。我正在使用 Fluent NHibernate,但我没有看到 NH 3.2 的新版本。我正在考虑使用附带的 Conform 映射器,但它似乎不允许使用复合 id。我无法更改数据库,所以我有一个限制。
在 Fluent NHibernate 中,我有这个(名称仅作为示例更改):
Schema("MY_SCHEMA");
Table("MY_TABLE");
CompositeId()
.KeyProperty(x => x.CompanyId, "COMPANY_ID")
.KeyProperty(x => x.OrderId, "ORDER_ID")
.KeyProperty(x => x.OrderDate, "ORDER_DATE")
.KeyProperty(x => x.ProgramId, "PROGRAM_ID");
How will I do this with Conform in NH 3.2?
谢谢, 保罗
I am upgrading to NHibernate 3.2. I was using Fluent NHibernate but I don't see a new build for NH 3.2. I am looking at using the included Conform mapper but it does not appear to allow for a composite id. I can't change the database so I have a constraint.
In Fluent NHibernate I had this (names changed for example only):
Schema("MY_SCHEMA");
Table("MY_TABLE");
CompositeId()
.KeyProperty(x => x.CompanyId, "COMPANY_ID")
.KeyProperty(x => x.OrderId, "ORDER_ID")
.KeyProperty(x => x.OrderDate, "ORDER_DATE")
.KeyProperty(x => x.ProgramId, "PROGRAM_ID");
How would I do this with Conform in NH 3.2?
Thanks,
Paul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试:
而且,我只是猜测,因为我无法弄清楚您的数据库,您可能会将密钥的单个部分映射为多对一(即旧的密钥多对一)会写成 hbm ),为此,请使用
cid.ManyToOne()
而不是cid.Property(..)
;You can try with:
And, I'm just guessing since I can't figura out your db, you would probably map the single portion of the key a many-to-one ( ie the old key-many-to-one you would write in hbm ), in order to do so, use
cid.ManyToOne()
instead ofcid.Property(..)
;