Call apoc from neo4jclient

Hi,

How do i call apoc procedure from neo4j client .net?
I want to count all nodes
My query is:
"
CALL db.labels() YIELD label
CALL apoc.cypher.run('MATCH (:'+label+') RETURN count(*) as count',{}) YIELD value
RETURN label, value.count
"
Thanks

you shouldn't need apoc to do this. Try the following:

match (n)
unwind labels(n) as l
return l, count(l)

ok, I see that maybe you want to use the APOC methods so you can leverage the count store. If so, try the following. It will return a map containing each label and its count.

        Map<String, Long> labelCountMap = neo4jClient
                .query("""
                        CALL db.labels() YIELD label
                        CALL apoc.cypher.run('MATCH (:'+label+') RETURN count(*) as count',{}) YIELD value
                        RETURN label, value.count as cnt""")
                .fetch()
                .all()
                .stream()
                .collect(Collectors.toMap(
                        x -> (String) x.get("label"),
                        x -> (long) x.get("cnt")
                ));

You simply use the .Call and .Yield methods of the client.

var query = client.Cypher
	.Call("db.labels()").Yield("label")
	.Call("apoc.cypher.run('MATCH (:'+label+') RETURN count(*) as count',{})").Yield("value")
	.Return((label, value) => new
	{
		Label = label.As<string>(),
		Count = Return.As<long>("value.count")
	});

var results = await query.ResultsAsync;

Thanks, this is what i tried to do, because it's much faster...