Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If list returns empty display message

Using MVC I am passing a Projects list to the view.

@if (Model.Projects != null && Model.Projects.Count > 0)
{
<fieldset>
    <table class="items" summary="@T("This is a table of the delivery Runs in your application")">
        <colgroup>
}

else
{
//no data available
}

Model.Projects.Count > 0 is saying:

operator > cant be applied to operands of type 'method group' and 'int'

like image 462
John Avatar asked Dec 11 '22 11:12

John


1 Answers

how about

Model.Projects.Count() > 0

or

Model.Projects.Any()

if you are using resharper, it will recommend you for Model.Projects.Any()

like image 107
Stay Foolish Avatar answered Dec 25 '22 15:12

Stay Foolish