How to create a connection using linq?

I am having this problem. I have this element where I have some images saved by their index. I want to find all the images on this item.
I am new to joins, so I am not familiar with the syntax of joins.
Usually, when I get data that does not require Linq, I do this. But when I try to do this, I can not get the data, because the data is in different tables.

var item = _db.items.Select(i => i);
+4
source share
1 answer

There are different types of associations. But here you can make a regular connection.

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

.
, , . "INNER JOIN " " ",

+2

Source: https://habr.com/ru/post/1620314/


All Articles