Есть две модели Категории:
public class Categories
{
public int CategoriesId { get; set; }
public int? StoroniyId { get; set; }
public string Name { get; set; }
public int? Parent_id { get; set; }
public ICollection<Products> Produkt { get; set; }
}
Parent_id идентификатор родительской категории
Модель Товары
public class Products
{
public int ProductsId { get; set; }
public string Name { get; set; }
public int CategoriesId { get; set; }
public virtual Categories Categoria { get; set; }
public int Possition { get; set; }
public bool Glass { get; set; }
public decimal price_opt { get; set; }
public decimal price_rrc { get; set; }
}
Никак не получается отобрать товары по родительской категории:
public async Task<IActionResult> Index()
{
var CatId = await _context.Categories.Where(c => c.Parent_id == 3).ToListAsync();
var applicationDbContext = _context.Products.Where(c => CatId.Equals(c.CategoriesId));
return View(await applicationDbContext.ToListAsync());
}
Как в этом случае правильно прописать оператор Where