重写 Fluent NHibernate 自动映射

发布于 2024-08-03 08:18:12 字数 558 浏览 4 评论 0原文

这是一个 Fluent NHibernate 新手问题,请耐心等待。

我有一组类,并且正在对其应用自动映射功能。

但我需要用唯一约束来标记其中一种技术的属性之一。

在 Fluent Wiki 中,它说

有时候有必要 对特定实体进行轻微更改, 不希望影响任何事情 别的;你可以用 with 来做到这一点 重写方法。

.Override(map => {
map.HasMany(x => x.Products) .Cascade.All(); });

但我无法弄清楚将 .Override 方法应用到哪个对象。

现在,我有

AutoPersistenceModel returnModel = AutoMap.AssemblyOf()

但 AutoPersistenceModel 对象没有 Override 方法。

有人可以给我一些简单的示例代码来引导我完成此操作,或者向我指出一些带有示例的链接吗?

谢谢。

This is a Fluent NHibernate newbie question, so bear with me.

I have a set of classes, and I'm applying the Automapping capabilities to it.

But I need to mark one of the properties of one of the techniques with a Unique constraint.

In the Fluent Wiki, it says

Sometimes it's necessary to make
slight changes to a specific entity,
without wishing to affect anything
else; you can do that with the with
Override method.

.Override(map => {
map.HasMany(x => x.Products)
.Cascade.All(); });

But I can't figure out what object to apply the .Override method to.

Right now, I have

AutoPersistenceModel returnModel = AutoMap.AssemblyOf()

But the AutoPersistenceModel object does not have an Override method.

Can someone give me some simple sample code to walk me through this, or point me to some links with some examples?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞美少年 2024-08-10 08:18:12

它确实在1.0 RTM。你像这样使用它:

AutoMap.AssemblyOf<Person>().Override<Shelf>(map =>
{
    map.HasMany(x => x.Products).Cascade.All();
});

It does have an Override method in the 1.0 RTM. You use it like this:

AutoMap.AssemblyOf<Person>().Override<Shelf>(map =>
{
    map.HasMany(x => x.Products).Cascade.All();
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文