【发布时间】:2026-01-27 16:40:01
【问题描述】:
我有一个约会表和一个约会结果表。在我的 Appointments 表上,我有一个 OutcomeID 字段,它具有 AppointmentOutcomes 的外键。我的 Fluent NHibernate 映射如下所示;
Table("Appointments");
Not.LazyLoad();
Id(c => c.ID).GeneratedBy.Assigned();
Map(c => c.Subject);
Map(c => c.StartTime);
References(c => c.Outcome, "OutcomeID");
Table("AppointmentOutcomes");
Not.LazyLoad();
Id(c => c.ID).GeneratedBy.Assigned();
Map(c => c.Description);
使用 NHibernate,如果我删除 AppointmentOutcome,则会引发异常,因为外键无效。我想要发生的是删除 AppointmentOutcome 会自动将引用 AppointmentOutcome 的任何约会的 OutcomeID 设置为 NULL。
这可以使用 Fluent NHibernate 吗?
【问题讨论】:
标签: nhibernate fluent-nhibernate reference foreign-keys