EOAttribute countAttribute = ERXEOAccessUtilities.createAggregateAttribute(editingContext, "COUNT", ERTag.NAME_KEY, _tagEntity.name(), Number.class, "i", "tagCount", "t2");
tagsFetchAttributes.addObject(countAttribute);
EOQualifier idQualifier = new ERXKey<Object>("id").in(itemPrimaryKeys);
EOFetchSpecification tagsFetchSpec = new EOFetchSpecification(_entity.name(), idQualifier, null);
EOSQLExpression tagsSqlExpression = sqlHelper.sqlExpressionForFetchSpecification(editingContext, tagsFetchSpec, 0, -1, tagsFetchAttributes);
NSMutableArray<EOAttribute> tagsGroupByAttributes = new NSMutableArray<EOAttribute>(new EOAttribute[] { tagNameAttribute, tagIDAttribute });
sqlHelper.addGroupByClauseToExpression(tagsGroupByAttributes, tagsSqlExpression);
// MS: This is lame, but the dynamic attribute is not properly resolved
// inside of EOSQLExpression because it's not actually part of the entity,