craigmain wrote:
Hi,
I am trying to figure out the best way to achieve the following.
A have a M:N relationship with an intermediate entity.
(They are vehicles, vehicle groups and the link vgv (vehicle-group-vehicle))
I have built a typed list, and am using the adapter classes.
I wish to display all the groups, regardless of whether they have vehicles in them or not.
The trick is that I MUST lazy load the vehicles, there is too much data to load them all at once. I want to build up the collection of vehicles as the user clicks to display the vehicles for a particular group.
I cannot find a way to slowly add to the collection. It seems to load them all at once.
DataAccessAdapter adapter = new DataAccessAdapter();
VehicleGroupVehicleListTypedList tl = new VehicleGroupVehicleListTypedList();
IRelationPredicateBucket bucket = (IRelationPredicateBucket) tl.GetRelationInfo();
adapter.FetchTypedList(tl.GetFieldsInfo(), tl, bucket);
Regards
Craig
I don't think what you are trying to do is possible with your current approach.
I would use two lists. The first list contains a list of vehicle groups; the second list contains vehicles.
When a user selects a group from the list, a second list gets populated, which uses the vehicle group PK that was selected in the first list as a predicate.
Now that I'm thinking about it, you probably could accomplish it using one list.
Just add the vehicle group PK that the user selects to the FK field of the vehicle table and refetch the list. The initial fetch (where you just want to display groups) will have to use a predicate that will not match ANY vehicles.
I hope that made sense. I just woke up.