When $count of expanded navigationproperty without any selected parameters then no values return because it is a cartesian not a UNION between parameters and count #175
#expandItemWhere
OPTIONAL {
{
{SELECT ?Zone_s ?ZonehasStationInZone_s {
?Zone_s <http://in4mium.com/londontube/ref/hasStationInZone> ?ZonehasStationInZone_s .
} LIMIT 0
}
VALUES(?ZonehasStationInZone_p){(<http://www.w3.org/2000/01/rdf-schema#comment>)(<http://www.w3.org/2000/01/rdf-schema#label>)(<http://www.w3.org/2003/01/geo/wgs84_pos#lat>)(<http://www.w3.org/2003/01/geo/wgs84_pos#lat_long>)(<http://www.w3.org/2003/01/geo/wgs84_pos#long>)(<http://in4mium.com/londontube/ref/osx>)(<http://in4mium.com/londontube/ref/osy>)(<http://in4mium.com/londontube/ref/postcode>)(<http://www.w3.org/1999/02/22-rdf-syntax-ns#subjectId>)}
?ZonehasStationInZone_s ?ZonehasStationInZone_p ?ZonehasStationInZone_o .
}
#expandItemWhereCount
UNION <---------------------------- UNION added to ensure results even when first part has no values
{ SELECT ?Zone_s (COUNT(DISTINCT ?ZonehasStationInZone_s) as ?ZonehasStationInZone_count)
WHERE {
?Zone_s <http://in4mium.com/londontube/ref/hasStationInZone> ?ZonehasStationInZone_s .
} GROUP BY ?Zone_s
}
}
Zone?$expand=hasStationInZone($count=true)&$select=subjectId,label&$orderby=label&$skip=0&$top=135