Wednesday, 21 August 2013

count the number of models with a certain Enum value

count the number of models with a certain Enum value

I want to get the number of models with a certain enum value. Something
like this:
(@Model.Status == "pending").Count().tostring())
or
(@Model.Status.Contains("pending").Count().tostring())
All the Models are passed back originally, and are then grouped by their
status. For example @Model.Count() will return all models (pending,
accepted etc.)
To put into context, this count will just appear as a number on an inbox,
so the end result would look like:
Pending (8) Accepted (3)....etc
Please note this is an asp.net MVC 4 app using razor 2 views.

No comments:

Post a Comment