views:

261

answers:

1

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.

+2  A: 

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

Bruno Lopes
As you say, I think the key is to make sure it's an IList, not a List. I'm just calling attention to that detail since I just read your answer and then proceeded to implement is as List<T>... maybe this comment will help someone else avoid that mistake.
Seth Petry-Johnson