传递到字典中的模型项的类型为"System.Data.Entity.DynamicProxies.Tbl_Categorys



我的网站有问题。我从控制器返回一个值以查看,但它不起作用,并显示以下消息:

传递到字典中的模型项的类型为'System.Data.Entity.DynamicProxies.Tbl_Categorys_26AF8D301E15B015E967BAE1AE74FFE13ABB70503E270542F343CFB2ADAB',但是这本字典需要类型为的模型项'RanaShop.Models.Domain.Tbl_User

public ActionResult Product(int id)
{
var q = (from a in db.Tbl_Categorys
where a.ID.Equals(id) && (a.ExitCount > 0)
select a).SingleOrDefault();
if (q == null)
{
ViewBag.Message = "No product to show";
ViewBag.Class = "alert alert-danger";
ViewBag.Style = "width: 40%;padding:15px;background-color:rgb(248,215,218);border 
radius:5px;text-align:right;top:20px;margin:0 auto";
return View();
}
return View(q);
}

查看

@model RanaShop.Models.Domain.Tbl_Categorys
@{
ViewBag.Title = @Model.Title;
Layout = "~/Views/Shared/_Layout.cshtml";
RanaShop.Models.Domain.ranaDBEntities db = new RanaShop.Models.Domain.ranaDBEntities();
}
<div style="@ViewBag.Style" class="@ViewBag.Class">
@if (ViewBag.Style != null)
{
<button type="button" class="close" data-dismiss="alert" style="float:left">×</button>
}
@Html.Raw(ViewBag.Message)
</div>
@{
if (Model != null)
{
<div class="container padding-top-10 ">
<div class="col-md-7 col-sm-7 col-xs-12">
<div class="well">
<strong>
@Model.Title
</strong>
<p class="help-block ">
@Model.City
</p>
</div>
<span class="line-height-30 " style="font-family:'B Titr'">
@Html.Raw(Model.Text)
</span>
<hr />
<div class="shop-item-price padding-bottom-10 ">
<span>
<strong>
Price : @Model.Price Dollor
</strong>
</span>
</div>
</div>
</div>
}
else
{
<p>
No product to show
</p>
}
}
}

我该怎么修?

我解决了我的问题,并在布局上出现了问题。我不应该把布局中的模型交给Tbl_User。我必须把它交给Tbl_Category,现在可以了。

相关内容

最新更新