# Return a node collection with relationship properties

**URL:** <https://community.neo4j.com/t/return-a-node-collection-with-relationship-properties/23553>\
**Category:** Newbie Questions\
**Tags:** cypher, relationship\
**Created:** [August 16, 2020, 1:56pm UTC](https://community.neo4j.com/t/return-a-node-collection-with-relationship-properties/23553 "2020-08-16T13:56:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielbahe](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/danielbahe/32/13112_2.png) [@danielbahe](https://community.neo4j.com/u/danielbahe)\
**Post date:** [August 16, 2020, 1:56pm UTC](https://community.neo4j.com/t/return-a-node-collection-with-relationship-properties/23553/1 "2020-08-16T13:56:43Z")

</div>

I want to get a node (A) with a relationship (R) and multiple nodes (B)

Relationship (R) have the property number.

And i want a query to return node (A) with multiple node (B) and for each node (B) return also the property number.

without 'number' property i was doing this:

```auto
 MATCH (a: Node)-[r]-(b: Node)
WHERE type(r) = 'MADE_OFF' AND a.id = 'randomId'
RETURN a, collect(b)

```

If I return 'a, collect(b), r' relationship data is unrelated to node (B)

Any suggestions?

Thanks!

---

<div class="post-metadata">

**Author:** ![Cobra](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/cobra/32/35243_2.png) [@Cobra](https://community.neo4j.com/u/Cobra)\
**Post date:** [August 16, 2020, 2:05pm UTC](https://community.neo4j.com/t/return-a-node-collection-with-relationship-properties/23553/2 "2020-08-16T14:05:38Z")

</div>

Hello @danielbahe 🙂

Can you write an example of what you would like to get as result?

Regards,  
Cobra

---

<div class="post-metadata">

**Author:** ![danielbahe](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/danielbahe/32/13112_2.png) [@danielbahe](https://community.neo4j.com/u/danielbahe)\
**Post date:** [August 16, 2020, 2:44pm UTC](https://community.neo4j.com/t/return-a-node-collection-with-relationship-properties/23553/3 "2020-08-16T14:44:06Z")

</div>

I'm mapping the result to .Net entities with [Neo4jMapper](https://neo4jmapper.tk/)  
I want to have  
EntityB: that correspond with Node (B)  
EntityB should have node(B) properties and the number property from the relationship

Thanks for help!

---

<div class="post-metadata">

**Author:** ![Cobra](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/cobra/32/35243_2.png) [@Cobra](https://community.neo4j.com/u/Cobra)\
**Post date:** [August 16, 2020, 2:49pm UTC](https://community.neo4j.com/t/return-a-node-collection-with-relationship-properties/23553/4 "2020-08-16T14:49:29Z")

</div>

We need to know the format (a string, a list, etc.) 🙂

Can you show what return the current query and what you would like to get?

---

<div class="post-metadata">

**Author:** ![danielbahe](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/danielbahe/32/13112_2.png) [@danielbahe](https://community.neo4j.com/u/danielbahe)\
**Post date:** [August 16, 2020, 3:26pm UTC](https://community.neo4j.com/t/return-a-node-collection-with-relationship-properties/23553/5 "2020-08-16T15:26:09Z")

</div>

Currently I'm doing this on C#

```auto
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());
        }

```

And I get this response

 ![image](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/a/aa2c3dfc222d9ba36c4b68eb3192cff54f6fc989.png)

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.

Thanks!

---

<div class="post-metadata">

**Author:** ![Cobra](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/cobra/32/35243_2.png) [@Cobra](https://community.neo4j.com/u/Cobra)\
**Post date:** [August 16, 2020, 3:41pm UTC](https://community.neo4j.com/t/return-a-node-collection-with-relationship-properties/23553/6 "2020-08-16T15:41:46Z")

</div>

```auto
MATCH (a:Recipe{id:'randomId'})-[r:MADE_OFF]-(b:Ingredient)
WITH a, b, r.quantity AS quantity
RETURN a, collect(b{.*, quantity})

```
