I have some code I'm trying to migrate from LLBL 1.x to 2.x. When I run it in 2.x I get this error message:
"The PrefetchPathElement you to tried to add is already added to this PrefetchPath.
Parameter name: elementToAdd"
Here's the code that worked in 1.x The part that is causing the error is the very last block of code, where I'm trying to add two subpaths to the responsePath. The two subpaths have to query the same table, but do so using different relations and filters on tables. In other words, they have to be able to return the combination of two sets of results from the SurveyResponseAnswers table. One set resulting from matrixLocationFilter and matrixLocationRelations and the other set resulting from itemLocationFilter and itemLocationRelations. In both cases, the tables being joined via the relations are where the constraints are applied (ie, SurveyMatrixSetFields.SurveyQuestionTypeID == questionTypes in one case and SurveyItemFields.SurveyQuestionTypeID == questionTypes in the other case.
I've tried quite a few variations, but all have led to the same error message. Any ideas on how this can work in LLBL 2?
IPrefetchPathElement2 mapPath = prefetchPath.Add(MailboxItemEntity.PrefetchPathProposalMailboxItemMap);
IPrefetchPathElement2 proposalPath = mapPath.SubPath.Add(ProposalMailboxItemMapEntity.PrefetchPathProposal);
proposalPath.SubPath.Add(ProposalEntity.PrefetchPathSurveyForm);
// matrix-based and survey item-based event dates
//
IRelationCollection matrixLocationRelations = new RelationCollection();
matrixLocationRelations.Add(SurveyResponseAnswersEntity.Relations.SurveyMatrixSetEntityUsingMatrixSetID);
IPredicateExpression matrixLocationFilter = new PredicateExpression();
matrixLocationFilter.Add(SurveyMatrixSetFields.SurveyQuestionTypeID == questionTypes);
// survey item-based event dates
//
IRelationCollection itemLocationRelations = new RelationCollection();
itemLocationRelations.Add(SurveyResponseAnswersEntity.Relations.SurveyItemEntityUsingItemID);
IPredicateExpression itemLocationFilter = new PredicateExpression();
itemLocationFilter.Add(SurveyItemFields.SurveyQuestionTypeID == questionTypes);
// this is weird, but works in LLBL 1.x: two subpaths get data from SurveyResponseAnswers table, using different filters
//
IPrefetchPathElement2 responsePath = proposalPath.SubPath.Add(ProposalEntity.PrefetchPathSurveyResponse);
responsePath.SubPath.Add(SurveyResponseEntity.PrefetchPathSurveyResponseAnswers, 0, matrixLocationFilter, matrixLocationRelations);
responsePath.SubPath.Add(SurveyResponseEntity.PrefetchPathSurveyResponseAnswers, 0, itemLocationFilter, itemLocationRelations);
Thanks,
Jack