我遇到的错误是
Delegate 'System.Func< MyWebSiteApp.Models.FontCategory,int,bool >' does not take 1 arguments
var s = db.FontCategories.Include("Fonts").
Where(s=>s.Fonts.Where(s=>s.Inactive == false).ToList();
有什么办法可以解决吗?
请您参考如下方法:
我认为您正在寻找 Linq Any。这将返回包含至少一种事件字体的字体类别:
var s = db.FontCategories.Include("Fonts").
.Where(s => s.Fonts.Any(s => s.Inactive == false)).ToList();
您现有代码的问题是 Where 需要一个 Predicate<FontCategory>类型(即返回 true/false 的 lambda),但您的 lambda 返回 IEnumerable<Font>反而。因此错误。
Determines whether any element of a sequence exists or satisfies a condition.
