How do I map a protected collection in Fluent NHib

2019-02-17 14:47发布

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.

1条回答
淡お忘
2楼-- · 2019-02-17 15:01

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).

查看更多
登录 后发表回答