Reputation: 61
I am building a Blazor app and am querying the db
var abcGetTblOppDetailsResult = await Abc.GetTblOppDetails(new Query() { Filter = $@"i=>i.OpportunityID=={args.OpportunityID}" });
tblOppDetails = ecosysGetTblOppDetailsResult;
I am using the results in tblOppDetails
to populate a component.
When there is nothinreturned from the query how do i check if tblOppDetails
is empty? i've tried ==null
but even if there is no data its not null so i'm stuck.
I've tried checking if teh count = 0 but every methoid i try from the intellisense tells me things like:
error CS0428: Cannot convert method group 'Count' to non-delegate type 'object'. Did you intend to invoke the method?
Please can someone help?
thanks
John
Upvotes: 1
Views: 1317
Reputation: 5481
As per error says, the result has a method called Count()
and you are probably using it as Count
.
So it will be like below:
var hasItems = result.Count() > 0;
Upvotes: 3
Reputation: 17397
The error says it all. You are probably doing
if (result.Count == 0) {
...
}
but there is no property Count
on result
. Use
if (result.Count() == 0) {
...
}
which calls the Linq extension method Count()
the error message is referring to.
Upvotes: 2