Hi, I have an EntityView2 which is result of a function returning a DefaultView.In this function I also prefetch related entities.
Now I wonder how can a filter on the related entities?
In my code I have the following code to filter on a related entity (main entity is HealthCarePlan and related entity is HealthCarePlanPattern)
hcpFilter = new PredicateExpression(new FieldCompareValuePredicate(HealthCarePlanPatternFields.PatternId, null, ComparisonOperator.Equal, pattern.PatternId));
hcpCollection.Filter = hcpFilter;
this however always return 0, so I wrote a seperate function like
private bool IsPatternPresentInCollection(int patternId)
{
IPredicateExpression patternFilter = new PredicateExpression(new FieldCompareValuePredicate(HealthCarePlanPatternFields.PatternId, null, ComparisonOperator.Equal, patternId));
EntityView2<HealthCarePlanPatternEntity> view;
foreach (HealthCarePlanEntity hcp in hcpCollection)
{
view = hcp.HealthCarePlanPattern.DefaultView;
view.Filter = patternFilter;
if (!view.Count.Equals(default(int)))
{
return true;
break;
}
}
return false;
}
this is working fine, but I think this is not best practice.
So my question if i have a View including related entities, how to filter on those related entities in this view?
TIA