I am in need of determining whether an IQueryable Method returns with Data, or “Empty” when applying it to a DataSource of a RadGrid like so:
RadGrid.DataSource = Method(x);
if (Method(x) == yyy)
{
button.Enabled = true;
}
else
{
button.Enabled = false;
}
I have tried using “null” in place of the “yyy” but with no success. When stepping through the code, the IQueryable Method returns as “Empty” but I am unsure of how to verify that using an If statement.
What does an IQueryable Method return as if it returns as Empty, and how can I verify that using an If Statement?
You can use Any() to check to see if there are any elements in the IQueryable:
(Or, alternatively, the shorter version:)