LINQ运算符'==';无法应用于类型为';方法组';和';int';
我有如下几点:LINQ运算符'==';无法应用于类型为';方法组';和';int';,linq,Linq,我有如下几点: var lst = db.usp_GetLst(ID,Name, Type); if (lst.Count == 0) { } 我在lst.Count==0下得到了一个令人震惊的谎言,它说: 运算符“==”不能应用于“方法组”类型的操作数,“int”是扩展方法,而不是属性。这意味着usp_GetLst可能返回IEnumerable(或某些等效项),而不是您所期望的IList或ICollection的派生项 // Notice we use l
var lst = db.usp_GetLst(ID,Name, Type);
if (lst.Count == 0)
{
}
我在lst.Count==0下得到了一个令人震惊的谎言,它说:
运算符“==”不能应用于“方法组”类型的操作数,“int”是扩展方法,而不是属性。这意味着usp_GetLst
可能返回IEnumerable
(或某些等效项),而不是您所期望的IList
或ICollection
的派生项
// Notice we use lst.Count() instead of lst.Count
if (lst.Count() == 0)
{
}
// However lst.Count() may walk the entire enumeration, depending on its
// implementation. Instead favor Any() when testing for the presence
// or absence of members in some enumeration.
if (!lst.Any())
{
}