Linq join returning duplicate results

Viewed 7110

I'm using LINQ to try to get all the clothes of my characters.

My query looks like this:

var characterList = from characters in ContextFactory.Instance.Characters
                    where characters.UserId == user.Id

                    join traits in ContextFactory.Instance.CharacterTraits
                    on characters.Id equals traits.CharacterId
                    join clothes in ContextFactory.Instance.CharacterClothes
                    on characters.Id equals clothes.CharacterId
                    select new { 
                        characters.Id, 
                        characters.Name, 
                        characters.Gender, 
                        characters.Level, 
                        characters.Money, 
                        characters.Bank, 
                        characters.LastLogin, 
                        characters.PlayedTime, 
                        traits, 
                        clothes };

Then I'm serializing it to use as JSON in javascript.

This code is returning an user for each clothe I have, I wanted it to group all the clothes in an array. How could I do that?

Current result:

Image

Thank you

2 Answers
Related