I'm mapping the result to .Net entities with Neo4jMapper
I want to have
EntityB: that correspond with Node (B)
EntityB should have node(B) properties and the number property from the relationship
public async Task<Result<Recipe>> GetById(Guid id)
{
var recipeId = id.ToString();
var session = GetStartedSession();
var result = await session.RunAsync(@"
MATCH (r:Recipe)-[c]-(i:Ingredient)
WHERE type(c) = 'MADE_OFF' AND r.id = $recipeId
RETURN r,collect(i)
", new { recipeId });
var recipe = (await result.ToListAsync()).Map((Recipe r, List<Ingredient> i) => new Recipe
{
Name = r.Name,
Id = r.Id,
Ingredients = new List<Ingredient>(i)
});
return Result.Success(recipe.FirstOrDefault());
}
The "MADE_OFF" relationship have a integer value named quantity. And I want to include the quantity value in the correct ingredient (only in the C# model)
I guess there are some cypher tricks to do that but I'm still trying.
Of course is possible with C# but I think that is better include this "logic" on the query than do it in memory on my app.