title: this call is ambiguous between the following methods or properties when using 2 models in a view c# razor
body: <p>I am having trouble using 2 models in a view in mvc.  When I try to reference the second model using razor it is giving me this error:</p>
  
  <pre><code>The call is ambiguous between the following methods or properties: 'System.Web.Mvc
  .Html.DisplayNameExtensions.DisplayNameFor&lt;System.Collections.Generic.IEnumerable
  &lt;MyApp.Models.Problems&gt;, string&gt;(System.Web.Mvc.HtmlHelper&lt;System.Collections.
  `Generic.IEnumerable&lt;MyApp.Models.Problems&gt;`(System.Linq.Expressions.Expression
  &lt;System.Func&lt;System.Collections.Generic.IEnumerable&lt;MyApp.Models.Problems&gt;,
  string&gt;&gt;)' and 'System.Web.Mvc.Html.DisplayNameExtensions.DisplayNameFor&lt;MyApp
  .Models.Problems&gt;,string(System.Web.Mvc.HtmlHelper&lt;Systems.Collections.Generic
  .IEnumerable&lt;MyApp.Models.Problems&gt;&gt;(System.Linq.Expressions.Expression&lt;System.Func
  &lt;MyApp.Models.Problems&gt;,string&gt;&gt;
  </code></pre>
  
  <p>This is how I call the model in the view:</p>
  
  <pre><code>@model IEnumerable&lt;MyApp.Models.Problems&gt;
  </code></pre>
  
  <p>This is my model being loaded in the view:</p>
  
  <pre><code>public class Problems
  {
    public int Id { get; set; }
    public string Title { get; set; }
  
    public IEnumerable&lt;MyApp.Models.Category&gt; Categories { get; set; }
    public IEnumerable&lt;MyApp.Models.Type&gt; Types {get; set;}
  }
  </code></pre>
  
  <p>These are the other 2 models inside that model:</p>
  
  <pre><code>public partial class Category
  {
     public int Id { get; set; }
     public string Title { get; set; }
  }
  
  public partial class Type
  {
    public int Id { get; set; }
    public int Order { get; set; }
    public string Description { get; set; }
  }
  </code></pre>
  
  <p>And this is how I am trying to call the model inside of the problems model using razor:</p>
  
  <pre><code>@foreach(Problems problems in Model)
  {
     foreach(Category category in problems.Categories)
     {
        @Html.DisplayNameFor(cat =&gt; @category.Title)
     }            
  }
  </code></pre>
  
  <p>There error I am getting is on this line:</p>
  
  <pre><code>@Html.DisplayNameFor(cat =&gt; @category.Title)
  </code></pre>
  
  <p>Any help for me to solve this problem would be amazing, I've spent a lot of time researching and can't seem to find the proper solution.  Thank you in advance!</p>
  
  <p>Edit to add controller:</p>
  
  <p>So what happens is a button is clicked and I am trying to populate a modal with the razor information.</p>
  
  <p>This is what I am using in the controller:</p>
  
  <pre><code>using System.Data;
  using System.Data.Entity;
  using System.Linq;
  using System.Net;
  using System.Web;
  using System.Web.Mvc;
  using MyApp.DTOs;
  using MyApp.Models;
  
      public class ProblemController : BaseController
          {
              private Context db = new Context();
          }
  </code></pre>
  
  <p>This is the button that kicks off the java script to create the modal I am trying to add it to(It bring in the Problem Id to the modal):</p>
  
  <pre><code>&lt;button class="modal" value= @item.Id role="button"&gt;Add Problem&lt;/button&gt;
  </code></pre>
  
  <p>Along with my javascript for the modal being created:</p>
  
  <pre><code>&lt;script&gt;
      $(function () {
          $("#myModal").dialog({
              autoOpen: false,
              height: 600,
              width: 500,
              modal: true,
              open: function () {
                  $("#accordion").accordion({ autoHeight: true });
              }
          });
          $(".modal").click(function () {
              defectId.value = $(this).attr('value');
              $("#myModal").dialog("open");
          })
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>When The form is submitted in the modal it sends in hardcoded radio buttons values to my controller to this method:</p>
  
  <pre><code>[HttpPost]
  public ActionResult AddProblem(Problems model)
  {
       List&lt;Category&gt; c = db.Categories.ToList();
       List&lt;Type&gt; t = db.Types.ToList();
  
       return View();
  }
  </code></pre>
  
  <p>This is my get method when the page is loaded:</p>
  
  <pre><code>public ActionResult GetProblem(ProjectProblemVM item)
          {
              var userid = getUserId();
              var userKey = getApiKey();
  
              // return problems
              var requestProb = new RestRequest("problem", Method.GET);
              requestProb.AddHeader("id", userid);
              requestProb.AddHeader("key", userKey);
              requestProb.RequestFormat = DataFormat.Json;
              var responseProb = Host.Execute(requestProb) as RestResponse;
  
              List&lt;Problems&gt; problems = JsonConvert.DeserializeObject&lt;List&lt;Problems&gt;&gt;(responseProb.Content);
              IEnumerable&lt;Problems&gt; problemsToReturn = problems.Where(d =&gt; d.ProjectId == item.ProjectId);
  
              return View(problemsToReturn);
          }
  </code></pre>