Hi Subodh,
First of all, I think you have an error in this code:
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.FAQCategoryEntity);
IPrefetchPathElement2 prefetchpathElement = prefetchPath.Add(FAQCategoryEntity.PrefetchPathFAQSubjects, 0, null, null, subjectSorter);
prefetchpathElement.SubPath.Add(FAQSubjectEntity.PrefetchPathFAQChildSubjects).SubPath.Add(FAQSubjectEntity.PrefetchPathFAQQuestions);
at the last SubPath.Add. I think you meant:
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.FAQCategoryEntity);
IPrefetchPathElement2 prefetchpathElement = prefetchPath.Add(FAQCategoryEntity.PrefetchPathFAQSubjects, 0, null, null, subjectSorter);
prefetchpathElement.SubPath.Add(FAQSubjectEntity.PrefetchPathFAQChildSubjects);
prefetchpathElement.SubPath.Add(FAQSubjectEntity.PrefetchPathFAQQuestions);
Then, if you include the _IPredicateExpression _and _IRelationCollection _when you add the PrefetchPathFAQSubjects, you will obtain the expected results :
// seting the filter for the sub-prefetch path
IPredicateExpression subPathFilter = new PredicateExpression();
subPathFilter.Add(
(FAQCategoryEntity.ID == 4 & (FAQSubjectEntity.ID == 14 | FAQSubjectEntity.ID == 15))
| (FAQCategoryEntity.ID == 5 & (FAQSubjectEntity.ID == 24 | FAQSubjectEntity.ID == 25)) );
// setting the additional relations for the sub-prefetch path so we would be able to include fields of others entities in the predicate.
IRelationCollection subPathAdditionalRelations = new RelationCollection();
subPathAdditionalRelations.Add(FAQSubjectEntity.Relations.FAQCategoryEntityUsingFAQCategoryId);
// when add the subPath, pass the filter and relations
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.FAQCategoryEntity);
prefetchPath.Add(FAQCategoryEntity.PrefetchPathFAQSubjects, 0, subPathFilter, subPathAdditionalRelations, subjectSorter);
...
I hope that was helpful