Using getmulti with relations is there a better way to do this filtering?
I have a samplerequestcollection which has 1 to many relation with sampleresult entities.
One samplerequest can have sampleresults from many laboratories.
Only when all sampleresults are, sampleresult.complete, do I want a samplerequest to show up in the evaluation list.
The problem is how to do this with one filter or getmulti or something fast as I have to do this a lot.
The only way I've found so far is: find all samplerequestentities with some sampleresults complete as the goodcollection
find all samplerequests with some sampleresults not done as the badcollection and then for each badrequest remove it from the list of goodrequests, to get the net list.
Here is the code:
Dim relations As New RelationCollection
relations.Add(SamplerequestEntity.Relations.SampleresultEntityUsingSampleid)
Dim bSort As ISortExpression = New SortExpression
bSort.Add(New SortClause(SamplerequestFields.Batchid, SortOperator.Ascending))
Dim gFilter As IPredicateExpression = New PredicateExpression
gFilter.Add(SampleresultFields.Complete = True)
gFilter.AddWithAnd(SamplerequestFields.Batched = True)
Dim goodSamps As New SamplerequestCollection
goodSamps.GetMulti(gFilter, 0, bSort, relations)
Dim bFilter As IPredicateExpression = New PredicateExpression
bFilter.Add(SampleresultFields.Complete = False)
bFilter.AddWithAnd(SamplerequestFields.Batched = True)
Dim badSamps As New SamplerequestCollection
badSamps.GetMulti(bFilter, 0, bSort, relations)
For Each sample As SamplerequestEntity In badSamps
Try
goodSamps.Remove(sample)
Catch ex As Exception
End Try
Next
Can someone see a more optimum way to get the samplerequestcollection?
TIA