我一直在尝试构建一个查询来报告测试用例的执行情况。 这是我将用作示例的非常简化的数据集: TestCase id Test Case Name Execution id Attribute Result 1 Log in to machine 1 Windows 7 Pass 1 Log in t ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
我有一个主从页面,当您单击请求上的查看详细信息时,它将在下表中填充数据。 当用户单击请求上的查看详细信息时,如何让第二个表填充具有匹配ID的数据? 当我现在进行遍历时,它会找到确实匹配的ID,但是如果我无法捕获所选的项目ID并去查找具有相同ID的行,它们将全部匹配。
这是我的请求控制器中的代码,可从请求详细信息中获取数据。 我正在查找ID,并尝试将其与所选项目进行比较,但即时通讯仍会取回所有记录。
//Requests Controller
public ActionResult Index(IA_RequestDetails iA_RequestDetails, IA_Requests iA_Requests, long? id = null)
{
List<IA_Requests> requestList = db.IA_Requests.ToList();
List<IA_RequestDetails> newRequestList = db.IA_RequestDetails.ToList();
var model = new InventoryAnalysisMasterDetailsModel();
model.RequestDetailsList = newRequestList;
model.RequestList = requestList;
if (id != null)
{
model.SelectedItems = newRequestList.Find(model => model.RequestId == id && model.SelectedItemsId == id);
model.SelectedItemsId = id;
}
return View(model);
}
我认为我正在使用foreach语句
foreach (var item in Model.RequestDetailsList)
{
<tr>
<td>
@item.RequestId
</td>
<td>
@item.Item
</td>
<td>
@item.LineID
</td>
<td>
@Html.ActionLink("Edit Item", "Edit", new { id = item.LineID, controller = "IA_RequestDetails" }) |
@Html.ActionLink("View Item Details", "Details", new { id = item.LineID, controller = "IA_RequestDetails" })
</td>
</tr>
}
很感谢任何形式的帮助。 谢谢。
这个问题让我有些困惑,但是想提供帮助。 Find将返回单个Item,因此SelectedItems有点令人困惑。
您想要的是以下内容:
newRequestList.Where(model => model.RequestId == id && model.SelectedItemsId == id);
如最初的想法,where子句是我所需要的。 这只是我在哪里以及做什么的问题:在if语句中添加where子句。 相当简单,对我来说有点麻烦。
model.RequestDetailsList = newRequestList.Where(x => x.RequestId == model.SelectedItemsId).ToList();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.