You can set a CustomFilter in the relation.
Custom filters for EntityRelations
The JOIN clauses themselves are determined from the relation objects, thus FK-PK compares which result in the ON clause. Sometimes it is important to specify additional predicates in this ON clause. You can do this by specifying an IPredicateExpression instance for the CustomFilter property of the EntityRelation you add to a RelationCollection. In the example below we add a custom predicate to the EntityRelation object of the relation Customer-Order and which filters on Order.ShipCountry="Mexico". It uses the example of Multi-entity filters.
// C#
IPredicateExpression customFilter = new PredicateExpression();
customFilter.Add(PredicateFactory.CompareValue(OrderFieldIndex.ShipCountry, ComparisonOperator.Equal, "Mexico"));
// ...
bucket.Relations.Add(CustomerEntity.Relations.OrderEntityUsingCustomerID).CustomFilter = customFilter;
// ...
' VB.NET
Dim customFilter As IPredicateExpression = New PredicateExpression()
customFilter.Add(PredicateFactory.CompareValue(OrderFieldIndex.ShipCountry, ComparisonOperator.Equal, "Mexico"))
' ...
bucket.Relations.Add(CustomerEntity.Relations.OrderEntityUsingCustomerID).CustomFilter = customFilter
' ...
Please pay special attention to the flag EntityRelation.CustomFilterReplacesOnClause. If this flag is set to true, it will make the join construction logic to use a specified CustomFilter as the ON clause instead of appending it with AND to the field relation clause.