Walaa,
Thanks for your time...
I'm working against a deadline so I'm not able to explain my situation in any detail but I can share the approach I settled on in the unlikely event it proves useful to someone else.
Wanted to do...
[constant date value] >= (
SELECT MAX(SomeTable.DateField)
FROM SomeTable
WHERE SomeTable.Field = ParentTable.Field)
Ended up doing...
EXISTS
(
SELECT SomeTable.Field2
FROM SomeTable
WHERE SomeTable.Field = Parent.Field
GROUP BY SomeTable.Field2
HAVING [constant date value] >= MAX(SomeTable.DateField)
)
The specific code I use to implement the general EXISTS scenario above...
private QueryDescriptor ConstructDateSetQuery(DateTime cutOffDate)
{
QueryDescriptor oQuery = new QueryDescriptor();
//Fields
oQuery.Fields = new EntityFields2(1);
oQuery.Fields.DefineField(TrcrPaymentScheduleDatesFields.PaymentScheduleId, 0);
//Filter
oQuery.Filter.Add(TrcrPaymentScheduleDatesFields.PaymentScheduleId == TrcrPaymentScheduleInfoFields.PaymentScheduleId);
//Group By
oQuery.GroupBy.Add(TrcrPaymentScheduleDatesFields.PaymentScheduleId);
//Having
oQuery.GroupBy.HavingClause = new PredicateExpression(TrcrPaymentScheduleDatesFields.ExpectedPayDate.SetAggregateFunction(AggregateFunction.Max) <= cutOffDate);
return oQuery;
}
QueryDescriptor oDateSetQuery = ConstructDateSetQuery(cutOffDate);
oQuery.Filter.Add(
new FieldCompareSetPredicate(
null,
null,
oDateSetQuery.Fields[0],
null,
SetOperator.Exist,
oDateSetQuery.Filter,
oDateSetQuery.Relations,
"",
-1,
null,
false,
oDateSetQuery.GroupBy
)
);
The FieldCompareSetPredicate supports the second alternative easily although GROUP BY feels less performant than the first method above.
By the way, I just HAVE to say that LLBL Gen Pro is absolutely brilliant. Saying that here is like preaching to the choir but I fealt something akin to a physical need to do it
.