This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
When I refer to the intersection entity directly however, it does work... i.e. I have a Listing Item with a ThroughAssociation as follows: public ThroughAssociation<CategoryListing, Category> Categories { get; private set; } public Listing(){ Categories = new ThroughAssociation<CategoryListing, Category>(_categoryListings);} If I refer to this.Categories, it's empty. If I refer to this.CategoryListings, it Lazy Loads properly. Additionally, after I refer to this.CategoryListings, this.Categories is properly populated. Perhaps there is some sort of issue with the "Load" triggering mechanism on through associations? |
|
|
Through associations are normally eager, and you need to do a bit of trickery to get them to lazy load correctly. As you've noted, once you've referenced the intersection collection -- thus causing that to load -- the through association works correctly. Therefore what you need to do is force the intersection collection to load when you access the through association. One way of doing this is something like this: private ThroughAssociation<CategoryListing, Category> _categories; public ThroughAssociation<CategoryListing, Category> Categories Note that the TA constructor refers to the CategoryListings *property* rather than the _categoryListings *field*. The access to the property results in the CategoryListings being populated if required; therefore by the time the Categories getter returns, the intersection collection is loaded and therefore the TA will be populated. |
|
|
You may want to note this in the documentation because this is the only way I could get the collection to load. I was unable to get the sample to work when the item was a field. Thanks. Joe |
|