Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I map a protected collection in Fluent NHibernate?

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.

like image 678
CalebHC Avatar asked Jul 15 '09 04:07

CalebHC


1 Answers

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

like image 141
Bruno Lopes Avatar answered Oct 29 '22 20:10

Bruno Lopes