[英]Missing a using directive or an assembly reference error
Looks like I am missing a using directive or an assembly reference. 好像我缺少using指令或程序集引用。
I made a CSHTML page to show a bill to user. 我制作了一个CSHTML页面,向用户显示帐单。 this is made as an empty page using TBL_Bill table.
使用TBL_Bill表将此作为空白页。 but I encounter an error while trying to read data from other tables such as Tbl_Product for products.
但是在尝试从其他表(例如Tbl_Product产品)读取数据时遇到错误。 The error tells me
错误告诉我
Tbl_Bill does not contain a definition for Tbl_Product and no accessible extension method accepting a first argument of type Tbl_Bill could be found.
Tbl_Bill不包含Tbl_Product的定义,并且找不到接受Tbl_Bill类型的第一个参数的可访问扩展方法。 Are you missing a using directive or an assembly reference?
您是否缺少using指令或程序集引用?
Code: 码:
@model IEnumerable<fardashahr3.Models.Domain.Tbl_Bill>
@using fardashahr3.Models.Repository
@using fardashahr3.Models.Plugins
@{
ViewBag.Title = "sales";
Layout = "~/Views/Shared/_Profile.cshtml";
}
<div class="part_left">
<div id="product_list" class="userpanel_bright_section">
@if (ViewBag.Error != null)
{
<div class="alert alert-danger">
<a class="close" style="cursor:pointer;" onclick="$('.alert').hide()">×</a>
@ViewBag.Error
</div>
}
@if (Model != null)
{
<h1 class="separator"> شماره فاکتور : @Model.InvoiceNumber</h1>
if (Model.Tbl_Product.Product_IsDownload == false)
{
<div class="table_style1" id="UpIBill">
according to the error you posted, it seems your model that you are using in the view ( @model IEnumerable<fardashahr3.Models.Domain.Tbl_Bill>
) is not having products details ( Tbl_Product
) inside of it to access them using the model in your markup ( Model.Tbl_Product.Product_IsDownload
). 根据您发布的错误,似乎您在视图中使用的模型(
@model IEnumerable<fardashahr3.Models.Domain.Tbl_Bill>
)内部没有产品详细信息( Tbl_Product
),无法在其中使用模型访问它们您的标记( Model.Tbl_Product.Product_IsDownload
)。 Check your model properties and pass the right model into your View. 检查模型属性,然后将正确的模型传递到视图中。
Because your Model is an IEnumerable<...>
, you need to iterate over it: 因为您的模型是
IEnumerable<...>
,所以您需要对其进行迭代:
@if (Model != null)
{
foreach (var bill in Model)
{
<h1 class="separator"> شماره فاکتور : @bill.InvoiceNumber</h1>
if (bill.Tbl_Product.Product_IsDownload == false)
{
....
}
}
}
It's impossible to say from here if bill.Tbl_Product
is the proper name to use for that property, but this should probably be enough to get you on your way. 从这里无法说出
bill.Tbl_Product
是否是用于该属性的正确名称,但这可能足以使您bill.Tbl_Product
。
Or if each bill
has a collection of products, then you will need to do something like 或者,如果每个
bill
都有一系列产品,那么您将需要执行以下操作
foreach (var product in bill.Products)
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.