Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.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,当我编译程序时,出现以下错误: “System.Collections.Generic.ICollection”不存在 包含“WIE_Ilosc”的定义,不包含扩展方法 “WIE_Ilosc”接受类型为的第一个参数 “System.Collections.Generic.ICollection”可以是 找到(是否缺少using指令或程序集引用?) 我必须在代码中更改什么才能使其正常工作 我的看法是: @model List<Webb.Models.Faktury> @{ La

当我编译程序时,出现以下错误:

“System.Collections.Generic.ICollection”不存在 包含“WIE_Ilosc”的定义,不包含扩展方法 “WIE_Ilosc”接受类型为的第一个参数 “System.Collections.Generic.ICollection”可以是 找到(是否缺少using指令或程序集引用?)

我必须在代码中更改什么才能使其正常工作

我的看法是:

@model List<Webb.Models.Faktury>
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <h2>Faktura VAT</h2>
    <p>
        Oryginal</p>
    <table width="100%">
        <tr>
            <td>ID</td>
            <td>Data S.</td>
            <td>Numer</td>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>@item.FAK_Id</td>
                <td>@item.FAK_DataS</td>
                <td>@item.Firma.FIR_Rachunek</td>
                <td>@item.Wierszes.WIE_Ilosc</td>
            </tr>
        }
    </table>

</body>
</html>
模型的一部分:

public Faktury()
        {
            this.Wierszes = new HashSet<Wiersze>();
        }
     .
     .
     .
     .

        public virtual ICollection<Wiersze> Wierszes { get; set; }
        public virtual Firma Firma { get; set; }
        public virtual Klienci Klienci { get; set; }
        public virtual Statusy Statusy { get; set; }
    }
public Faktury()
{
this.Wierszes=new HashSet();
}
.
.
.
.
公共虚拟ICollection Wierszes{get;set;}
公共虚拟公司{get;set;}
公共虚拟Klienci Klienci{get;set;}
公共虚拟状态状态{get;set;}
}

查看razor代码中的这一行

<td>@item.Wierszes.WIE_Ilosc</td>

由于Wierszes未在Linq查询中投影,因此不会
项。Wierszes
始终为空FAKTURY具有此
Wierszes
属性,延迟加载可能会为他提供数据。有一段时间没有使用EF:)
<td>@item.Wierszes.WIE_Ilosc</td>
@foreach (var item in Model)
{
   <tr>
       <td>@item.FAK_Id</td>
       <td>@item.FAK_DataS</td>
       <td>
            @if(item.Wierszes!=null)
            {
               foreach(var v in item.Wierszes)
               {
                   <span>@v.WIE_Ilosc</span>
               }
            }
        </td>
    </tr>
}