Yes, this is absolutely possible. This is very easy to do.
To avoid going to the database multiple times, you must Prefetch whatever tables you're looking to use.
It would help to know if you're using Self-Servicing or Adapter, as you fetch slightly differently. I'm using Self-Servicing here.
So, you'll need a PredicateExpression to determine what AgencyIDs you want to filter by:
Imports MyDataObjects.HelperClasses
Dim myFilters as New PredicateExpression
myFilters.Add(AgencyQuestionsFields.AgencyID = 123)
You will also need to use AgencyQuestionsCollection.GetMulti() to perform the fetch. Unless you want to lazy-load (go to the DB every time, NOT recommended)... you will need to specify what Entities to Prefetch during your initial fetch.
Here is an example:
'Define Prefetches
Dim myPrefetches As New PrefetchPath(CType(EntityType.AgencyQuestionsEntity, Integer))
myPrefetches.Add(AgencyQuestionsEntity.PrefetchPathCaseQuestionsCollectionViaQuestions)
'Define Relations
Dim myRelations As New RelationCollection
myRelations.Add(AgencyQuestionsEntity.Relations.QuestionsEntityUsingAgencyId)
myRelations.Add(QuestionsEntity.Relations.CaseQuestionsEntityUsingQuestionId)
'Go!
Dim myAgencyQuestionsCollection As New AgencyQuestionsCollection
myAgencyQuestionsCollection.GetMulti(myFilters, 0, Nothing, myRelations, myPrefetches)
Hope this helps!
Ryan