Skip to content

Lack of Collect Method #484

@DOsterholz

Description

@DOsterholz

Describe the bug
I am currently looking for a method like Collect. Unfortunately, I can't find it. The only possibility I have found so far is to use the collect functionality of the cypher via a raw string. Am I missing the method or does it really not exist?

Versions:

  • Neo4jClient 5.1.17
  • Bolt or Http BoltGraphClient
  • .NET Version .NET 8
  • Server Version 5.24.0

To Reproduce

[HttpGet("product-detail")]
public async Task<IActionResult> GetProductDetailsNeo4J(string productId, string language = "en")
{
    var result = await _neo4jClient.Cypher
        .Match("(p:Product {Id: $productId})-[:HAS]->(pv:ProductValue)-[:BELONGS_TO]->(a:Attribute)")
        .OptionalMatch("(pv)-[:TRANSLATED]->(vt:ValueTranslation)")
        .WithParam("productId", productId)
        .WithParam("language", language)
        .Return(() => new
        {
            de = Return.As<string>("p.De"),
            en = Return.As<string>("p.En"),
            properties = Return.As<List<Dictionary<string, object>>>(
                "COLLECT({ attributeName: CASE $language WHEN 'en' THEN a.En ELSE a.De END, " +
                "value: CASE $language WHEN 'en' THEN vt.En ELSE vt.De END })"
            )
        })
        .ResultsAsync;

    if (result == null || !result.Any())
    {
        return NotFound($"Product with ID {productId} not found.");
    }

    return Ok(result.First());
}

Expected behaviour
I thought there might be a “.Collect” C# method.

Additional context
The implementation is realized within an ASP Core application in a controller.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions