I'm trying to write a single query which will include one of the two conditions, based on an input variable:
!(from o in db.Products.Where(x => x.Company_ID == cid && x.IsDeleted != true)
or
(from o in db.Products.Where(x => x.Company_ID == cid && x.IsDeleted != true)
My current method, covering the former condition, is as follows. I have included productExists, which will be the parameter which determines whether I want condition #1 or #2 from above.
public IQueryable<ProductImportViewModel> AllImports(int id, bool productExists)
{
return (from t1 in db.Products_Staging
where (t1.ImportFileId == id) && !(from o in db.Products.Where(x => x.Company_ID == cid && x.IsDeleted != true)
select o.ProductName).Contains(t1.ProductName)
select new ProductImportViewModel
{
Id = t1.Id
}
}
If anybody could help me with this, I'd be much appreciated.