MVC 5 asp.net Inside Foreach Each Sum Related Data from other table
<p>Models are , </p>

<pre><code>ModelA:

 public int AId       {get;set;}
 public float Amount {get;set;}

ModelB:
  public int   BId              {get;set;}
  public float RequestAmount    {get;set;}
  public int AId                {get;set;}
  public virtual ModelA ModelA  {get;set;}
</code></pre>

<p>now when i want to list the ModelA, there as many item in ModelB related ModelA
i want to calculate <strong>RequestAmount</strong>  and list in ModelA foreach list:</p>

<pre><code>   public ActionResult Index()
    {
        var modelA = db.ModelA.Include(c =&gt; c.ModelB);
        return View(modelA.ToList());
    } 
</code></pre>

<p>this will be the view:</p>

<pre><code>@model IEnumerable&lt;test.Models.ModelA&gt;


@foreach (var item in Model) {
    &lt;tr&gt;
        &lt;td&gt;
            @Html.DisplayFor(modelItem =&gt; item.AId)
        &lt;/td&gt;
        &lt;td&gt;
            @Html.DisplayFor(modelItem =&gt; item.Amount)
        &lt;/td&gt;
        &lt;td&gt;
            **Here need to calcut or SUM value from ModelB only related to this**
        &lt;/td&gt;
    &lt;/tr&gt;

}
</code></pre>