无法使用模型中的剃刀 foreach

razor foreach in model can not be used

美好的一天,

我有这个视图模型

public class ProjectTypeViewModel
{      
    public string CategoryName{ get; set; }
    public IEnumerable<ProjectType> Tipo { get; set; }
}
public class ProjectType
{
    [Required]
    public Guid Id { get; set; }
    [MaxLength(512)]
    [Required]
    public string Type{ get; set; }
    [Required]
    public string AddedBy { get; set; }
    public Category Category{ get; set; }
    public Guid? CategoryId{ get; set; }

}

我想 return 将 ProjectTypeViewModel 添加到我的视图中

@model  List<MyProject.ViewModels.ProjectTypeViewModel>
@foreach(var tipo in Model )
{

}

我这里有问题,我的模型显示以下错误:

foreach statement can not operate in variables of type ProjectTypeViewModel because does not contain a definition for GetEnumerator.

我做错了什么?

谢谢

您需要访问如下模型中的列表

@model  MyProject.ViewModels.ProjectTypeViewModel
@foreach(var tipo in Model.Tipo)
{

}