Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 每行都有总计,我只想得到一次_C#_Asp.net Mvc - Fatal编程技术网

C# 每行都有总计,我只想得到一次

C# 每行都有总计,我只想得到一次,c#,asp.net-mvc,C#,Asp.net Mvc,我想总结一下我的账单总额。我只想得到一个总数。 现在我得到了数据库中每一行的数据 实际上,输出是这样的 Stats Nombre de factures: 2 Grand total des factures 71.97 71.97 <=== the total is coming twice. I will like to get only one grand total Stats 名义制造:2 工厂总计 71.97 71.97(一) } 试

我想总结一下我的账单总额。我只想得到一个总数。 现在我得到了数据库中每一行的数据

实际上,输出是这样的

 Stats

    Nombre de factures: 2

   Grand total des factures

   71.97
   71.97    <=== the total is coming twice.  I will like to get only one grand total
Stats
名义制造:2
工厂总计
71.97
71.97(一)
}

试试这个,您不需要检查模型中的每个项目,您已经在做总和了

@model IEnumerable<Tp1WebStore3.Models.Facture>

 @{
     ViewBag.Title = "Stats";
 }

 <h2>Stats</h2>

 <p>
     Nombre de factures: @Model.Count()  
 </p>
 <table>
     <tr>
         <th>

             <p> Grand total des factures</p>
         </th>

     </tr>

     <tr>
          <td>
              @Model.Sum(i => i.TotalFact)
          </td>
     </tr>

 </table>
@model IEnumerable
@{
ViewBag.Title=“Stats”;
}
统计数据

制造名称:@Model.Count()

工厂总计

@Model.Sum(i=>i.TotalFact)
@model IEnumerable<Tp1WebStore3.Models.Facture>

 @{
     ViewBag.Title = "Stats";
 }

 <h2>Stats</h2>

 <p>
     Nombre de factures: @Model.Count()  
 </p>
 <table>
     <tr>
         <th>

             <p> Grand total des factures</p>
         </th>

     </tr>

     <tr>
          <td>
              @Model.Sum(i => i.TotalFact)
          </td>
     </tr>

 </table>