I’ve already asked similar question but it was not very precise, so I will do it again.
Suppose I have a model where one entity includes other entity. Is there any way to access a property of child entity withing a linq query? Here is the example:
string category = "something";
IEnumerable<string> Items = _itemsRepository.GetItems()
.Where(i => i.Product.Category == category)
.OrderBy(i => i.ItemId);
In a clause “Where” I want to access child entity’s property “Category”, (this chunk of code doesn’t work). Table “Items” contains foreign key “ProductId” of table “Products”.
So here I want to select items which product’s category equals “something”. How can it be done?
Thank You in advance!
1 Answer