我有以下内容:
db.Products.Where(p=>p.Sectors.Where(s=>s.website_id == websiteObj.website_id)).Count();
websiteObj 不为 null 并且具有有效数据。产品和部门之间存在多对多的关系。此外,部门和网站之间存在一对多的关系。我不能直接访问网站上的产品,我必须通过网站相关部门。
无论如何,这个例子有效:
db.Sectors.Where(p=>p.website_id == websiteObj.website_id)).Count();
但问题是第一个 LINQ 查询给了我以下错误:
Delegate 'System.Func<BusinessObjects.Product,int,bool>' does not take 1 arguments.
Cannot convert lambda expression to type 'string' because it is not a delegate type.
还有其他几个错误。
无论如何,我做错了什么?这是我第一次尝试使用 LINQ。提前致谢。