Hi all,
We have a use case where we want to filter DOM Instance fetching. We have two field descriptors for the filter. We want to exclude a DOM instance if it satisfies both conditions. The excluded items are lists (not single ones).
Let’s say we have field descriptors 1 and 2. I want to exclude DOM Instances that have fieldDescriptor1 value A and fieldDescriptor2 value B, fieldDescriptor1 value C and fieldDescriptor2 value D, …The excluded items are (A, B), (C, D), (E, F), …
I tried the following:
var filter1 = excludedItems.Select(e => DomInstanceExposers.FieldValues.DomInstanceField(fieldDescpitorId1).NotEqual(e.Item1));
var filter2 = excludedItems.Select(e => DomInstanceExposers.FieldValues.DomInstanceField(fieldDescpitorId2).NotEqual(e.Item2));
var filters1 = new ANDFilterElement<DomInstance>(filter1.ToArray());
var filters2 = new ANDFilterElement<DomInstance>(filter2.ToArray());
var filters = new ANDFilterElement<DomInstance>(filters1, filters2);
When using the above filtering, the query discards all items that have fieldDescriptor1 value A (whatever the value of fieldDescriptor2 is) and vice versa. So, I want a filter that combines the two filters, meaning discard an instance if fieldDescriptor1 has value A and fieldDescriptor2 has value B.
Hi Fenta,
A filter like that should be possible by having one of these filters for each exclusion pair:
NOT ( 'Field 1 = A' AND 'Field 2 = B' )
If you then AND these together, this should result in the exclusion of those pairs. In code, it could look like this:
var relationsToExclude = new[] {
("A", "B"),
("C", "D"),
("E", "F"),
};var filters = relationsToExclude.Select(one => new ANDFilterElement<DomInstance>(
DomInstanceExposers.FieldValues.DomInstanceField(_fieldDescriptorId1).Equal(one.Item1),
DomInstanceExposers.FieldValues.DomInstanceField(_fieldDescriptorId2).Equal(one.Item2)).NOT());var fullFilter = new ANDFilterElement<DomInstance>(filters.ToArray());
It does seem however, that the evaluation of this type of filter may result in a very large operation as the DB layer in DataMiner may convert this to another format that results in a OR filter with 2^n sub filters, where 'n' equals the amount of combinations you have. I would thus recommend keeping this filter combination very short (<10), or simply avoid the need for a large exclusion query, as this in itself is sometimes a red flag when building solutions. Feel free to share more details about this solution, I'll gladly help find alternative ways to get a performance and scalable result.