DateTime start, end;
string typeId;
//assign values to variables
IPredicate between = New FieldBewteenPredicate(DoctorRequests.DateTimeRequested, start, end);
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.Relations.Add(RequestDoctorLocationEntity.Relations.DoctorLocationOnDoctorLocationId);
bucket.Relations.Add(RequestDoctorLocationEntity.Relations.RequestOnRequestId);
bucket.PredicateExpression.Add(between);
IGroupByCollection group = new GroupByCollection();
group.HavingClause = new PredicateExpression(DoctorRequests.Name.SetAggregateFunction(AggragetFunction.Count) > 5);
IPredicateExpression filter = new PredicateExpression();
filter.Add(between);
filter.Add(DoctorRequests.DoctorInvolvementTypeId == typeId);
filter.Add(new FieldSetPredicate(DoctorRequests.Name, RequestDoctorLocationFields.Name, SetOperator.In, bucket, 0, null, group));
adapter.FetchEntityView(MyView, filter);
It would look something like this. I wrote this from memory so there may be some overload errors.