4

I got this problem. i have this item where i have some images saved on by their index. I want to find all of the images on that item.
I am new with joins so i am not familiar with the syntax of joins.
Normally when i recive data unsing Linq i do like this. But when i try to do it like this i cannot recive the data since the data is in different tabels.

var item = _db.items.Select(i => i);

1 Answers1

2

There are different types of joins. But here is a way you could do a regular join.

public List<Image> GetImagesInfo(int tradeItemId)
    {
        var query = (from item in _db.ImagesOnTradeItems
                     join image in _db.Images on item.imageId equals image.id
                     where item.tradeItemId == tradeItemId
                     select image);
        return query.ToList();
    }

here i return the result as a list after i query through the result.
Here is a link to a question on joins hope you can use this. What is the difference between "INNER JOIN" and "OUTER JOIN"?

Community
  • 1
  • 1
Code_Viking
  • 618
  • 1
  • 8
  • 26