User-821857111 posted
If Count() and Any() did not work, it was most likely a result of passing in a dynamic type as a parameter value somewhere. In turn, that changes the return type of the Query() method to simply "dynamic".
For example, you might have a query that produces a single value:
var categoryId = db.QueryValue(@"SELECT CategoryId FROM Categories WHERE CategoryName = 'Beverages'");
categoryId is a dynamic type. If you pass that into a Query method call, the return type becomes dynamic:
var data = db.Query(@"SELECT * FROM Products WHERE CategoryId = @0", categoryId);
If you use Visual Studio and hover over var in the line above, you will see simply "dynamic". Any and Count are extension methods on Enumerable, but dynamic does not support extension methods - hence the error message you see. So you can specify
the return type explicitly:
IEnumerable<dynamic> data = db.Query(@"SELECT * FROM Products WHERE CategoryId = @0", categoryId);
or cast the dynamic:
var data = db.Query(@"SELECT * FROM Products WHERE CategoryId = @0", (int)categoryId);
Then the return type will support Any() and Count() and all other extensions methods.