c# - 当我将此部分视图用于我在 mvc 中使用两个类的元组的视图中时,如何将 basemodel 类传递给部分视图
问题描述
我有一个视图,其中我使用两个类的元组来呈现它。
@model Tuple<SAP.DTO.ViewData.IndentmstViewData, SAP.DTO.ViewData.IndentdetViewData>
我正在从控制器传递数据
IndentmstViewData model1 = new IndentmstViewData();
IndentdetViewData model2 = new IndentdetViewData();
var model = new Tuple<IndentmstViewData, IndentdetViewData>(model1, model2);
model.Item1.GetMenuData = GetMenuByUser();
return View(model);
但是在我的布局页面中,我使用了部分页面来呈现菜单,使用了部分页面模型:
@model SAP.DTO.ViewData.BaseViewData
当我运行应用程序时,它会引发错误:
传入字典的模型项的类型为“System.Tuple`2[SAP.DTO.ViewData.IndentmstViewData,SAP.DTO.ViewData.IndentdetViewData]”,但此字典需要类型为“SAP.DTO.ViewData”的模型项.BaseViewData'。
解决方案
推荐阅读
- laravel - 雄辩与多个地方
- pdf - 使用 IText 7 签署 Pdf 时的 Java 堆空间
- tensorflow - 如何将两个模型恢复到一个会话中,然后分别保存它们?
- ngrx - 具有多个动作的 Ngrx 效果
- android - 在 android 模拟器上运行 linphone - 无法加载可选库 ffmpeg-linphone
- codeigniter - 我如何使用我的 Codeigniter API 使用电子
- python-3.6 - csvkit 库中的 csvsql 缺少包如何修复?
- python - 在循环中扩展变量的名称
- sql-server - 使用 GROUP BY 和 HAVING 从一个表选择到另一个表
- corda - 在corda中设置Multi-Notary