Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
LINQ运算符'==';无法应用于类型为';方法组';和';int';_Linq - Fatal编程技术网

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())
{

}