如何在Fluent NHibernate中映射受保护的集合? [英] How do I map a protected collection in Fluent NHibernate?

查看:97
本文介绍了如何在Fluent NHibernate中映射受保护的集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试在Fluent中使用Reveal属性,但是我无法用集合来编译它。我希望实体中的一个集合受到保护,除了实体本身之外,不能在任何地方访问。这可能吗?谢谢

编辑:

下面是我正在使用的代码,

  HasMany< Trip>(x => Reveal.Property< Trip>(_ trips)); 

我也试过这段代码,
$ b $ (<_p $ p> HasMany< Trip>(Reveal.Property< Organization>(_ trips));

每次运行我的应用程序时,NHibernate都会说它不能映射到Property,或者抛出未知例外。假设组织有一个 IList < Trip>

(旅行));

>

代码应该可以工作。
检查它是一个属性,并且你有getter和setter的保护(私人将不起作用,因为NHibernate将代理集合进行lazyloading)。

I have tried using the Reveal property in Fluent but I can't get it to compile with a collection. I want one of my collections in an entity to be protected and not accessible anywhere except in the entity itself. Is this possible? Thanks

Edit:

Here's the code I'm trying to use,

HasMany<Trip>(x => Reveal.Property<Trip>("_trips"));

I've also tried this code as well,

HasMany<Trip>(Reveal.Property<Organization>("_trips"));

Everytime my app runs, NHibernate says it can't map to "Property" or it throws an unknown exception.

解决方案

Assuming that Organization has a IList<Trip> the

HasMany<Trip>(Reveal.Property<Organization>("_trips"));

code should work. Check that it's a property and that you have protected getters and setters (privates will not work, since NHibernate will want to proxy the collection for lazyloading).

这篇关于如何在Fluent NHibernate中映射受保护的集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆