I’m creating ViewModels in my MVC application. We are using automapper for domain model to view model conversion. My question is I keep getting a circular reference error when doing ajax stuff in MVC (seems like it’s the JavaScriptSerializer that’s causing problems), so instead of getting back a list of Projects, I just need the count (because that’s all my view model needs). Here is a sample of the hierarchy. Thanks in advance for any advice!
public class ProjectViewModel
{
public int ProjectID { get; set; }
[Required]
[UIHint("Project Name")]
public string Name { get; set; }
public ICollection<ProjectGroupViewModel> ProjectGroups { get; set; }
}
public class ProjectGroupViewModel
{
public int ProjectGroupID { get; set; }
[Required]
public string Name { get; set; }
//THIS is what I Want to have as int ProjectCount
public ICollection<ProjectViewModel> Projects { get; set; }
}
1 Answer