I have this code and it works as excepted:
For i = 0 To _SelectedFields.Count - 1
For j = 0 To _SelectedFields(i).DataFields.Count - 1
For k = 0 To _Aggregations.Count - 1
If Not _Aggregations(k).AggregatedExpr.Contains(_SelectedFields(i).DataFields(j).FieldName) Then
If Not FieldInGroupBy.Contains(_SelectedFields(i).DataFields(j).FieldName) Then
MessageBox.Show("Missing selected field '" & _SelectedFields(i).DataFields(j).FieldName & "' at GROUP BY.", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
End If
Next
Next
Next
I though, I make it with linq:
If Not _SelectedFields.Any(Function(SelectedField) SelectedField.DataFields.Any(Function(DataField)
If Not _Aggregations.Any(Function(Aggregation) Aggregation.AggregatedExpr.Contains(DataField.FieldName)) Then
Return FieldInGroupBy.Contains(DataField.FieldName)
Else
Return True
End If
End Function)) Then
MsgBox("error")
End If
In my opinion, the above is the same as the working one. But it doesn't work as intended.
Have you any ideas, why this doesn't work?
If your first bit of code is your intended behaviour then I think this suffices: