Click here to Skip to main content
15,904,655 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi there,

I am trying to do a join in SQL. I do the join but it always returns the first object instead of a collection of objects. Here is my code:
C#
IEnumerable<FigureModel> data = (from figure in context.Figures
                                                join rarity in context.Rarities on figure.RarityID equals rarity.RarityID
                                                join figureKeywords in context.FigureKeywords on figure.FigureID equals figureKeywords.FigureID
                                                join keywords in context.Keywords on figureKeywords.KeywordID equals keywords.KeywordID
                                                where figure.Name.Contains(QueryString) && ((powerMap & figure.PowerMap) == powerMap) &&
                                                      (SelectedSet == null ? true : figure.SetID == SelectedSet.SetID)
                                                select new FigureModel
                                                {
                                                    Cost = figure.Cost,
                                                    Name = figure.Name,
                                                    Rarity = rarity.Name,
                                                    SetNumber = figure.SetNumber.ToUpper(),

                                                });


A figure links to the FigureKeywords table which then links Keywords table. The problem is that if I try query figureKeywords it isnt giving me a collection its giving me a single instance of FigureKeywords?

Thanks in advance,

- Dom
Posted

1 solution

Hi DominicZA,
Hope this helps you
http://stackoverflow.com/questions/2723985/linq-join-2-listts[^]

If u need any more help, just ask here.

Thanks
Ganesh
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900