I have a ICollection of Projects in my user class
public ICollection<Project> Projects { get; set; }
When I try to render the count of projects in my view, it gives an error
<h2>You have @Model.Projects.Count() projects....</h2>
Any help appreciated.
ICollection
doesn't have a Count
method, it has a Count property. You are probably getting confused with the LINQ Count extension method which is supported on an IEnumerable
interface.
Just remove the parenthesis at the end of the Count
call i.e.
<h2>You have @Model.Projects.Count projects...</h2>