The following sample was copied from the LLBLGen Pro documentation,
"Using the generated code - Field expressions and aggregates - Aggregate functions in scalar queries"
DataAccessAdapter adapter = new DataAccessAdapter();
IExpression productPriceExpression = new Expression(
OrderDetailsFields.Quantity, ExOp.Mul, OrderDetailsFields.UnitPrice);
IPredicate filter = PredicateFactory.CompareValue(OrderDetailsFieldIndex.OrderId, ComparisonOperator.Equal, 10254);
[b]decimal orderPrice = (decimal)adapter.GetScalar(OrderDetailsFields.OrderId,
productPriceExpression, AggregateFunction.Sum, filter);[/b]
you can AggregateFunction.Count instead of AggregateFunction.Sum, and you can always have the Count(*) by having the Count(PK)
So mainly the following will get you going:
int nCount = (int)adapter.GetScalar(EntityNameFields.PK, AggregateFunction.Count);