我让它工作正常:
var results = db.GetProducts().Where(p => p.ProductName.Equals(searchQuery, StringComparison.OrdinalIgnoreCase));
当我使用 || 比较以使我的新查询为:
var results = db.GetProducts().Where(p => p.ProductName.Equals(searchQuery, StringComparison.OrdinalIgnoreCase)) || db.GetProducts().Where(p => p.ProductId.ToString().Equals(searchQuery, StringComparison.OrdinalIgnoreCase));
我最终得到:
Error 1 Operator '||' cannot be applied to operands of type
'System.Collections.Generic.IEnumerable<Uppgift_1.Models.MyProduct>' and
'System.Collections.Generic.IEnumerable<Uppgift_1.Models.MyProduct>' C:\Home\Programming
\cSharp\projects\MVC_projects\Uppgift_1\Uppgift_1\Controllers\ProductController.cs
23 27 Uppgift_1
如果我想在搜索查询中包含这两个语句,我该怎么办?