I am trying to convert this short SQL statement into linq but I am facing some difficulties, here’s my latest attempt, apparently it has an error:
SQL:
select ProductID from products where
categoryID in (select categoryID from categories_sub
where categoryID='15' and category_sub_name = 'chiffon')
Linq:
’15’ and ‘chiffon’ is replaced by parameter ‘cID’ and ‘subCatID’ here:
IQueryable<Categories_Sub > cat = (from c in db.Categories_Sub
where c.CategoryID == cID
& c.Category_Sub_ID == subCatID
select c);
var subcat = (from c in db.Products
where cat.Contains(c.ProductID)
select c);
Try