I have something like the following:
var lst = db.usp_GetLst(ID,Name, Type); if (lst.Count == 0) { }
I get a swigly lie under lst.Count == 0 and it says:
Operator '==' cannot be applied to operands of type 'method group' and 'int'
Enumerable.Count
is an extension method, not a property. This means usp_GetLst
probably returns IEnumerable<T>
(or some equivalent) rather than a derivative of IList<T>
or ICollection<T>
which you expected.
// 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()) { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With